You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(server): ensure consistency between CLI serve entrypoints regarding help and strict (#9809)
This PR aims to fix inconsistencies across all the CLI entry points
around `--help` and strict.
This PR is technically breaking but I feel like most users would
consider many of these things to be bug fixes (e.g. `--help` runs the
server 😂). @Tobbe we can talk in more detail about all the changes.
Here's a non exhaustive list of all the changes
- the `api-root-path` alias was added to `@redwoodjs/api-server` to make
the options the same across `yarn rw serve` and `yarn rw-server`
- refactored `@redwoodjs/api-server` entrypoint to handle `--help` and
yargs strict mode and; we also moved parsing into the if block cause it
was running too early (during import)
- for the CLI (`yarn rw ...`) yargs strict mode wasn’t exiting with exit
code 1 when unknown arguments were passed; now it does and it prints to
stderr in the case there is an error
- for `@redwoodjs/web-server`, passing `--help` would just run the
server since we were using `yargsParser` instead of `yargs`; also added
strict mode here and like the others; kept the options the same between
the entrypoints
- updated the server-tests tests to handle all these cases
- spiked out some more tests to write to ensure we're covering all the
similarities and differences before refactoring everything
---------
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
exports[`serve web (/Users/dom/projects/redwood/redwood/packages/web-server/dist/server.js) errors out on unknown args 1`] =`
4
+
"rw-web-server
5
+
6
+
Start server for serving only the web side
7
+
8
+
Options:
9
+
--help Show help [boolean]
10
+
--version Show version number [boolean]
11
+
-p, --port [number] [default: 8910]
12
+
--socket [string]
13
+
--apiHost, --api-host Forward requests from the apiUrl, defined in
14
+
redwood.toml, to this host [string]
15
+
16
+
Unknown arguments: foo, bar, baz
17
+
"
18
+
`;
19
+
20
+
exports[`serve web (/Users/dom/projects/redwood/redwood/packages/web-server/dist/server.js) fails if apiHost isn't set and apiUrl isn't fully qualified 1`] =`
21
+
"Error: If you don't provide apiHost, apiUrl needs to be a fully-qualified URL. But apiUrl is /.redwood/functions.
]) fails if apiHost isn't set and apiUrl isn't fully qualified 1`] =`
49
+
"[31mError[39m: If you don't provide [35mapiHost[39m, [35mapiUrl[39m needs to be a fully-qualified URL. But [35mapiUrl[39m is [33m/.redwood/functions[39m.
0 commit comments