@farm.js/cli 0.1.0-beta.1 → 0.1.0-beta.10

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 CHANGED
@@ -8,4 +8,16 @@ Farm.js is currently in beta.
8
8
  npm install @farm.js/cli@beta
9
9
  ```
10
10
 
11
+ Upgrade every published `@farm.js/*` dependency in an app to one release channel:
12
+
13
+ ```bash
14
+ farm upgrade --latest
15
+ farm upgrade --beta
16
+ farm upgrade --latest --dry-run
17
+ ```
18
+
19
+ `--latest` selects the newest stable release. `--beta` selects the newest beta release. The CLI
20
+ detects npm, pnpm, Yarn, or Bun from the project and leaves `workspace:`, `file:`, and other local
21
+ package references unchanged.
22
+
11
23
  See the [Farm.js repository](https://github.com/farming-labs/farm.js) for documentation, examples, and support.
package/bin/farm.js CHANGED
@@ -33,7 +33,7 @@ function collectOption(value, previous) {
33
33
  program
34
34
  .command("dev")
35
35
  .description("Start development server")
36
- .option("-p, --port <port>", "Port to run the server on", "3000")
36
+ .option("-p, --port <port>", "Override the port to run the server on")
37
37
  .option("-r, --root <root>", "Root directory", process.cwd())
38
38
  .option("--cron", "Run configured cron routes in-process during development")
39
39
  .action(async (options) => {
@@ -43,12 +43,12 @@ program
43
43
  {
44
44
  root: options.root,
45
45
  },
46
- parseInt(options.port),
46
+ options.port === undefined ? undefined : parseInt(options.port, 10),
47
47
  );
48
48
  if (options.cron) {
49
49
  const { startFarmCronScheduler } = require("../dist/index.js");
50
50
  const address = server.httpServer?.address();
51
- const port = typeof address === "object" && address ? address.port : parseInt(options.port);
51
+ const port = typeof address === "object" && address ? address.port : 3000;
52
52
  const scheduler = await startFarmCronScheduler({
53
53
  root: options.root,
54
54
  url: `http://localhost:${port}`,
@@ -80,6 +80,59 @@ program
80
80
  }
81
81
  });
82
82
 
83
+ const authCommand = program.command("auth").description("Manage Farm-native authentication");
84
+
85
+ authCommand
86
+ .command("migrate")
87
+ .description("Create or update the Farm Auth database schema")
88
+ .option("-r, --root <root>", "Root directory", process.cwd())
89
+ .option("-c, --config <config>", "Path to farm config file")
90
+ .action(async (options) => {
91
+ try {
92
+ const { migrateFarmAuth } = require("../dist/index.js");
93
+ await migrateFarmAuth({
94
+ root: options.root,
95
+ configPath: options.config,
96
+ });
97
+ } catch (error) {
98
+ console.error("Failed to migrate Farm Auth:", error);
99
+ process.exit(1);
100
+ }
101
+ });
102
+
103
+ program
104
+ .command("upgrade")
105
+ .description("Upgrade installed Farm.js packages to a stable or beta release")
106
+ .option("-r, --root <root>", "Project root", process.cwd())
107
+ .option("--latest", "Upgrade to the latest stable release")
108
+ .option("--beta", "Upgrade to the latest beta release")
109
+ .option("--dry-run", "Print the package-manager commands without installing")
110
+ .action(async (options) => {
111
+ try {
112
+ if (options.latest === options.beta) {
113
+ throw new Error("Choose exactly one release channel: --latest (stable) or --beta.");
114
+ }
115
+
116
+ const { formatFarmUpgradePlan, upgradeFarm } = require("../dist/index.js");
117
+ const result = await upgradeFarm({
118
+ root: options.root,
119
+ channel: options.beta ? "beta" : "latest",
120
+ dryRun: options.dryRun,
121
+ });
122
+ console.log(formatFarmUpgradePlan(result.plan));
123
+ console.log(
124
+ result.executed
125
+ ? `Upgraded ${result.plan.packages.length} Farm package${
126
+ result.plan.packages.length === 1 ? "" : "s"
127
+ } to ${result.plan.channel}.`
128
+ : "Dry run only. No packages were changed.",
129
+ );
130
+ } catch (error) {
131
+ console.error("Failed to upgrade Farm packages:", error);
132
+ process.exit(1);
133
+ }
134
+ });
135
+
83
136
  program
84
137
  .command("generate")
85
138
  .description("Generate route/API types and integration schema artifacts")