@farm.js/cli 0.1.0-beta.36 → 0.1.0-beta.38

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 CHANGED
@@ -35,6 +35,44 @@ function collectOption(value, previous) {
35
35
  return [...(previous || []), value];
36
36
  }
37
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
+
38
76
  program
39
77
  .command("dev")
40
78
  .description("Start development server")
@@ -480,4 +518,49 @@ program
480
518
  }
481
519
  });
482
520
 
483
- program.parse();
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("Opt in to 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.");
560
+ }
561
+ });
562
+
563
+ program.parseAsync().catch((error) => {
564
+ console.error("Farm CLI failed:", error);
565
+ process.exitCode = 1;
566
+ });
@@ -1,29 +1,8 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.js");
23
2
  let node_fs = require("node:fs");
24
3
  let node_fs_promises = require("node:fs/promises");
25
4
  let node_path = require("node:path");
26
- node_path = __toESM(node_path);
5
+ node_path = require_rolldown_runtime.__toESM(node_path);
27
6
  //#region src/ui-feature-registry.ts
28
7
  async function installUIFeature(input) {
29
8
  const feature = input.definition.ui;
@@ -2553,12 +2532,6 @@ function escapeRegExp(input) {
2553
2532
  return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2554
2533
  }
2555
2534
  //#endregion
2556
- Object.defineProperty(exports, "__toESM", {
2557
- enumerable: true,
2558
- get: function() {
2559
- return __toESM;
2560
- }
2561
- });
2562
2535
  Object.defineProperty(exports, "addFarmIntegration", {
2563
2536
  enumerable: true,
2564
2537
  get: function() {
@@ -2572,4 +2545,4 @@ Object.defineProperty(exports, "listFarmIntegrationProviders", {
2572
2545
  }
2573
2546
  });
2574
2547
 
2575
- //# sourceMappingURL=add-integration-D5mff3xX.js.map
2548
+ //# sourceMappingURL=add-integration-Bz7WjUfh.js.map