@farm.js/cli 0.1.0-beta.5 → 0.1.0-beta.51
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/bin/farm.js +148 -9
- package/dist/{add-integration-CdVfiPjG.mjs → add-integration-7hf9WI7e.mjs} +147 -140
- package/dist/add-integration-7hf9WI7e.mjs.map +1 -0
- package/dist/{add-integration-Xc0p-k-m.js → add-integration-Bz7WjUfh.js} +149 -169
- package/dist/add-integration-Bz7WjUfh.js.map +1 -0
- package/dist/add-integration.js +1 -1
- package/dist/add-integration.mjs +1 -1
- package/dist/build.js +5 -3
- package/dist/build.js.map +1 -1
- package/dist/build.mjs +5 -3
- package/dist/build.mjs.map +1 -1
- package/dist/index.js +812 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +796 -108
- package/dist/index.mjs.map +1 -1
- package/dist/rolldown-runtime-VH7oDXx4.js +28 -0
- package/dist/telemetry.js +347 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/telemetry.mjs +337 -0
- package/dist/telemetry.mjs.map +1 -0
- package/package.json +3 -2
- package/dist/add-integration-CdVfiPjG.mjs.map +0 -1
- package/dist/add-integration-Xc0p-k-m.js.map +0 -1
package/bin/farm.js
CHANGED
|
@@ -16,20 +16,63 @@ const { program } = require("commander");
|
|
|
16
16
|
const { version } = require("../package.json");
|
|
17
17
|
|
|
18
18
|
const banner = `
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
░██████████ ░███ ░█████████ ░███ ░███ ░█████ ░██████
|
|
20
|
+
░██ ░██░██ ░██ ░██ ░████ ░████ ░██ ░██ ░██
|
|
21
|
+
░██ ░██ ░██ ░██ ░██ ░██░██ ░██░██ ░██ ░██
|
|
22
|
+
░█████████ ░█████████ ░█████████ ░██ ░████ ░██ ░██ ░████████
|
|
23
|
+
░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██
|
|
24
|
+
░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██
|
|
25
|
+
░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██████ ░██████
|
|
24
26
|
`;
|
|
25
27
|
|
|
26
|
-
program
|
|
28
|
+
program
|
|
29
|
+
.name("farm")
|
|
30
|
+
.description("Farm.js CLI - A framework for product-integrated apps")
|
|
31
|
+
.version(version);
|
|
27
32
|
program.addHelpText("beforeAll", `${banner}\n`);
|
|
28
33
|
|
|
29
34
|
function collectOption(value, previous) {
|
|
30
35
|
return [...(previous || []), value];
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
function telemetryCommandPath(command) {
|
|
39
|
+
const segments = [];
|
|
40
|
+
let current = command;
|
|
41
|
+
while (current && current !== program) {
|
|
42
|
+
segments.unshift(current.name());
|
|
43
|
+
current = current.parent;
|
|
44
|
+
}
|
|
45
|
+
return segments.join(":");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function telemetryDeployTarget(commandPath, options) {
|
|
49
|
+
if (commandPath !== "deploy") return undefined;
|
|
50
|
+
if (options.vercel) return "vercel";
|
|
51
|
+
if (options.cloudflare) return "cloudflare";
|
|
52
|
+
if (options.netlify) return "netlify";
|
|
53
|
+
if (options.custom) return "custom";
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
program.hook("preAction", async (_command, actionCommand) => {
|
|
58
|
+
const commandPath = telemetryCommandPath(actionCommand);
|
|
59
|
+
if (commandPath.startsWith("telemetry")) return;
|
|
60
|
+
const {
|
|
61
|
+
resolveFarmTelemetryCommand,
|
|
62
|
+
showFarmTelemetryNotice,
|
|
63
|
+
trackFarmCommand,
|
|
64
|
+
} = require("../dist/telemetry.js");
|
|
65
|
+
await showFarmTelemetryNotice();
|
|
66
|
+
const command = resolveFarmTelemetryCommand(commandPath);
|
|
67
|
+
if (!command) return;
|
|
68
|
+
const options = actionCommand.opts();
|
|
69
|
+
await trackFarmCommand({
|
|
70
|
+
command,
|
|
71
|
+
packageVersion: version,
|
|
72
|
+
deployTarget: telemetryDeployTarget(commandPath, options),
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
33
76
|
program
|
|
34
77
|
.command("dev")
|
|
35
78
|
.description("Start development server")
|
|
@@ -80,6 +123,26 @@ program
|
|
|
80
123
|
}
|
|
81
124
|
});
|
|
82
125
|
|
|
126
|
+
const authCommand = program.command("auth").description("Manage Farm-native authentication");
|
|
127
|
+
|
|
128
|
+
authCommand
|
|
129
|
+
.command("migrate")
|
|
130
|
+
.description("Create or update the Farm Auth database schema")
|
|
131
|
+
.option("-r, --root <root>", "Root directory", process.cwd())
|
|
132
|
+
.option("-c, --config <config>", "Path to farm config file")
|
|
133
|
+
.action(async (options) => {
|
|
134
|
+
try {
|
|
135
|
+
const { migrateFarmAuth } = require("../dist/index.js");
|
|
136
|
+
await migrateFarmAuth({
|
|
137
|
+
root: options.root,
|
|
138
|
+
configPath: options.config,
|
|
139
|
+
});
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error("Failed to migrate Farm Auth:", error);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
83
146
|
program
|
|
84
147
|
.command("upgrade")
|
|
85
148
|
.description("Upgrade installed Farm.js packages to a stable or beta release")
|
|
@@ -124,6 +187,7 @@ program
|
|
|
124
187
|
)
|
|
125
188
|
.option("--dialect <dialect>", "SQL dialect for Drizzle generation (postgres, mysql, sqlite)")
|
|
126
189
|
.option("-o, --output <output>", "Custom output path")
|
|
190
|
+
.option("--check", "Fail when committed generated framework types are stale")
|
|
127
191
|
.action(async (options) => {
|
|
128
192
|
try {
|
|
129
193
|
const { generateFarmArtifacts } = require("../dist/index.js");
|
|
@@ -133,6 +197,7 @@ program
|
|
|
133
197
|
orm: options.orm,
|
|
134
198
|
dialect: options.dialect,
|
|
135
199
|
output: options.output,
|
|
200
|
+
check: options.check,
|
|
136
201
|
});
|
|
137
202
|
} catch (error) {
|
|
138
203
|
console.error("Failed to generate Farm artifacts:", error);
|
|
@@ -149,6 +214,7 @@ program
|
|
|
149
214
|
.option("--host <host>", "Host of a running local app")
|
|
150
215
|
.option("--url <url>", "Base URL of a running Farm app")
|
|
151
216
|
.option("--offline", "Inspect project files without probing a running app")
|
|
217
|
+
.option("--fix", "Apply safe additive corrections without overwriting application files")
|
|
152
218
|
.option("--timeout <ms>", "Live runtime probe timeout in milliseconds", "1200")
|
|
153
219
|
.option("--json", "Print machine-readable JSON")
|
|
154
220
|
.action(async (options) => {
|
|
@@ -165,6 +231,7 @@ program
|
|
|
165
231
|
host: options.host,
|
|
166
232
|
url: options.url,
|
|
167
233
|
offline: options.offline,
|
|
234
|
+
fix: options.fix,
|
|
168
235
|
timeoutMs,
|
|
169
236
|
});
|
|
170
237
|
console.log(options.json ? JSON.stringify(report, null, 2) : formatFarmDoctorReport(report));
|
|
@@ -175,6 +242,30 @@ program
|
|
|
175
242
|
}
|
|
176
243
|
});
|
|
177
244
|
|
|
245
|
+
program
|
|
246
|
+
.command("explain <path>")
|
|
247
|
+
.description("Explain how a URL maps to a Farm route and deployment runtime")
|
|
248
|
+
.option("-r, --root <root>", "Root directory", process.cwd())
|
|
249
|
+
.option("-c, --config <config>", "Path to farm config file")
|
|
250
|
+
.option("--json", "Print machine-readable JSON")
|
|
251
|
+
.action(async (pathname, options) => {
|
|
252
|
+
try {
|
|
253
|
+
const { explainFarmRoute, formatFarmRouteExplanation } = require("../dist/index.js");
|
|
254
|
+
const explanation = await explainFarmRoute(pathname, {
|
|
255
|
+
root: options.root,
|
|
256
|
+
configPath: options.config,
|
|
257
|
+
});
|
|
258
|
+
console.log(
|
|
259
|
+
options.json
|
|
260
|
+
? JSON.stringify(explanation, null, 2)
|
|
261
|
+
: formatFarmRouteExplanation(explanation),
|
|
262
|
+
);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.error("Failed to explain Farm route:", error);
|
|
265
|
+
process.exit(1);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
178
269
|
program
|
|
179
270
|
.command("preview")
|
|
180
271
|
.description("Create a public URL for a running local Farm app")
|
|
@@ -413,15 +504,63 @@ program
|
|
|
413
504
|
.option("--cloudflare", "Deploy to Cloudflare")
|
|
414
505
|
.option("--netlify", "Deploy to Netlify")
|
|
415
506
|
.option("--prod", "Deploy to production (Vercel: uses prebuilt output)")
|
|
507
|
+
.option("--plan", "Print the resolved deployment plan without building or deploying")
|
|
416
508
|
.option("--custom", "Use your own credentials (not Farm.js managed)")
|
|
417
509
|
.action(async (options) => {
|
|
418
510
|
try {
|
|
419
511
|
const { deployFarm } = require("../dist/index.js");
|
|
420
512
|
await deployFarm(options);
|
|
421
513
|
} catch (error) {
|
|
422
|
-
|
|
423
|
-
|
|
514
|
+
const code = error?.name === "FarmDeployError" ? ` [${error.code}]` : "";
|
|
515
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
516
|
+
console.error(`Failed to deploy${code}: ${message}`);
|
|
517
|
+
process.exitCode = 1;
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const telemetryCommand = program
|
|
522
|
+
.command("telemetry")
|
|
523
|
+
.description("Control anonymous Farm.js product telemetry");
|
|
524
|
+
|
|
525
|
+
telemetryCommand
|
|
526
|
+
.command("status")
|
|
527
|
+
.description("Show the current telemetry setting")
|
|
528
|
+
.action(async () => {
|
|
529
|
+
const { getFarmTelemetryStatus } = require("../dist/telemetry.js");
|
|
530
|
+
const status = await getFarmTelemetryStatus();
|
|
531
|
+
console.log(`Anonymous telemetry: ${status.enabled ? "enabled" : "disabled"}`);
|
|
532
|
+
console.log(`Active for this command: ${status.active ? "yes" : "no"}`);
|
|
533
|
+
console.log(`Setting source: ${status.source}`);
|
|
534
|
+
if (status.reason) console.log(`Reason: ${status.reason}`);
|
|
535
|
+
console.log(`Local anonymous ID: ${status.anonymousId ? "created" : "not created"}`);
|
|
536
|
+
console.log(`Configuration: ${status.configFile}`);
|
|
537
|
+
console.log("Privacy details: https://farmjs.dev/docs/telemetry");
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
telemetryCommand
|
|
541
|
+
.command("enable")
|
|
542
|
+
.description("Enable anonymous Farm.js product telemetry")
|
|
543
|
+
.action(async () => {
|
|
544
|
+
const { setFarmTelemetryEnabled } = require("../dist/telemetry.js");
|
|
545
|
+
const status = await setFarmTelemetryEnabled(true);
|
|
546
|
+
console.log("Anonymous Farm.js telemetry is enabled.");
|
|
547
|
+
if (!status.active && status.reason)
|
|
548
|
+
console.log(`It is inactive here because ${status.reason}.`);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
telemetryCommand
|
|
552
|
+
.command("disable")
|
|
553
|
+
.description("Opt out and delete the local anonymous installation ID")
|
|
554
|
+
.action(async () => {
|
|
555
|
+
const { setFarmTelemetryEnabled } = require("../dist/telemetry.js");
|
|
556
|
+
const status = await setFarmTelemetryEnabled(false);
|
|
557
|
+
console.log("Anonymous Farm.js telemetry is disabled and its local ID was deleted.");
|
|
558
|
+
if (status.enabled) {
|
|
559
|
+
console.log("An environment variable currently overrides the saved setting.");
|
|
424
560
|
}
|
|
425
561
|
});
|
|
426
562
|
|
|
427
|
-
program.
|
|
563
|
+
program.parseAsync().catch((error) => {
|
|
564
|
+
console.error("Farm CLI failed:", error);
|
|
565
|
+
process.exitCode = 1;
|
|
566
|
+
});
|