-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webiny CLI / create-webiny-project
Improvements
#4045
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added database setup, and also version of NPM.
…rovements-merged-next
…erged-next' into adrian/cwp-cli-ux-improvements-merged-next
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This PR introduces multiple changes that improve UX of Webiny and
create-webiny-project
CLIs. In the followingsection, we outline all the changes we made.
Changes are listed in no particular order.
create-webiny-project
The following list of changes are all related to our
create-webiny-project
CLI, used for creating new Webiny projects.1. Offer Users To Immediately Deploy the Newly Created Project
Once the initial project creation has been done, users are immediately asked if they want to proceed with the initial deployment.
2. Yarn Logs Shown Only In Case of an Error
When packages are installed, users are no longer bombarded by Yarn logs. Instead, a simple spinner is shown, and the logs are shown only in case of an error.
3. Graceful Error Handling
Although we haven't implemented any graceful error handling yet (because of the lack of errors in our analytics), there's now a way to do it (by throwing an instance of the new
GracefulError
class.4. Separate Tracking of Error and Graceful Error Events
We now separately track error and graceful error events. Basically, if an instance of a
GracefulError
class was thrown, acreate-webiny-project-error-graceful
event will be sent to our analytics. Otherwise, the usualcreate-webiny-project-error
event gets sent.5. Full Logs Sent In Analytics
Prior to this PR, in case of an error, in our analytics, we'd only have very basic error information, not containing any details on why the error actually happened. This has now been addressed.
Having more information in our analytics will enable us to better detect what's bothering users and address those obstacles.
6. Error Log File Contains More Info
The
create-webiny-project-logs.txt
file that gets created in case an error has occurred during the initial project creation now contains all the logs that were printed in user's terminal. Previously, similarly to 5., the file would only contain basic information.7. Catch
.gitignore
Commit ErrorsPrior to this PR, even if the user had
git
set up, if the initial commit of the.gitignore
file failed, the whole project creation would fail. This looks like a trivial error and something that should not definitely break the whole project creation process.8.
create-webiny-project-end
Event Being Sent In Case Of An ErrorPrior to this PR, the
create-webiny-project-end
would be sent even in case of an error. This is not the expected logic. Thecreate-webiny-project-end
must be sent only in case the project creation was successful.9. Restricting Users to Node18/Node20
Users won't be able to install Webiny in case their Webiny version is different from 18 or 20. We've decided to go with a bit harder version limiting just because we've seen users experiencing issues with newer version 21 of Node.
By further forcing specific Node versions, we're minimizing the possibility of unexpected issues for users.
Note 1: We'll add more versions as we start supporting more.
Note 2: The new limitations are also reflected in our docs. We'll be released with the 5.40.0 release.
Webiny CLI
The following list of changes are all related to our Webiny CLI.
1. Pulumi Output Hidden By Default
From now on, Pulumi deployment logs are hidden by default. The only thing that the user will see is the "Deploying..." spinner and that's it.
A couple of notes.
--deployment-logs
flag.--deployment-logs
has been passed or not.2. Refactor - Multiple
BasePackageBuilder
ClassesWe've refactored internal code dealing with building of packages. Basically, instead of having everything in a single file, we've divided the code into a couple of classes.
Bonus: Simplified
worker.js
CodeThe
worker.js
file, whose code is responsible for calling the package's build script has also been simplified. In the file, we're no longer overridingconsole
object's methods. Now, we're simply interceptingprocess.stdout.write
andprocess.stderr.write
calls, where we store all messages into local variables, and then ensuring those get included when responding back to the main process.This makes it easier to deal with output produced within worker threads / subprocesses, and making sure the whole output is being received by the main process.
3. Lazy-import Modules By Calling
require
Inside FunctionsIn a couple of places, I've moved the
require
calls inside a function. This ensures the required modules are not immediately loaded, but only when actually needed (lazy loaded).Was hoping this would speed up our CLI a bit, but did not see any visible performance improvements. 🙁
4. Graceful Error Handling
We've added the ability to gracefully handl errors (similarly to the graceful error handling we've added in the
create-webiny-project
CLI).Right now, we've only gracefully handling two deployments-related errors, but over time, we can add more.
For example, in case of a pending Pulumi operation, users will receive a more friendly error message, as visible in the screenshot:
5. Improved Analytics
Analytics has been improved. We've added the following.
From now on, deployment errors that user experience will also be included in analytics events. This will help us with improving the stability, by detecting what errors are users often experiencing and then gracefully handling them. Prior to this PR, the only piece of info that we had was essentially "command failed", which doesn't help.
We've added the
newUser
flag when sending analytics events. ThenewUser
flag remainstrue
, until a user manages to fully deploy a Webiny instance on their machine. Once that's done, thenewUser
flag remainsfalse
forever.We've added the new
ci
flag when sending analytics events. This will enable us to group events by those sent from a developer's machine and events sent from a CI/CD provider.When deploying the project in full (via
yarn webiny deploy
), in case an instance ofGracefulError
was thrown, thecli-project-deploy-error-graceful
will be sent to our analytics. In other cases, the usualcli-project-deploy-error
event will be sent.When deploying apps separately, e.g.
yarn webiny deploy api --env dev
, a newpulumi-command-deploy-start
event is sent. Like with the existingcli-project-deploy
events, thepulumi-command-deploy-end
is sent when a command has successfully been completed, andpulumi-command-deploy-error
/pulumi-command-deploy-error-graceful
when a command has errored.6. Build/Watch Packages - Only Using Worker Threads When Needed
The
build
andwatch
commands distribute multiple package build/watch processes across multiple Node worker threads.Prior to this PR, this was done even when only one package needed to be built/watched, which, in fact, is not required. From now on, if a single package is to be built/watched, worker threads are not used. The build/watch is happening in the same process in which Webiny CLI was invoked.
This makes it a lot easier to print out original logs from build tools like Webpack. Ultimately, this enabled us to have the default Webpack (webpackbar) logs printed to the user, making the DX a bit more pleasant than what it used to be.
Building GraphQL API application code:
Building Admin application code:
7. Improved Multiple Packages Build Output
As mentioned above, we can now finally have the default Webpack output in terminal. But what about multiple packages?
Here we've also done some improvements. When multiple packages are being built, we're now using the Listr library to show a nice list of packages that are being built.
8. Removed Pre-5.29-related Code
In the code, there were still a couple of checks related to pre-5.29 Webiny versions. These checks are no longer needed, and have been removed.
9. Deploy Lifecycle Events Class Plugins
Prior to this PR, hooking into deploy-related lifecycle events was done via a simple JS object-style plugin:
This can now be done with dedicated classes:
For example:
10. Improved
webiny deploy
outputOn top of everything that's already mentioned in other points, a couple of extra improvements were done to the
webiny deploy
command.execa
and callingyarn webiny deploy ...
, but directly. Makes things a bit more stable / faster.Project Details
section is now always printed. This way the user does not have to run thewebiny info
command (check the next section for updates on that one).11. Refreshed
webiny info
CommandThe
webiny info
command has been visually refreshed a bit.Note that the command is now also called internally at the end of the full project deployment (via
webiny deploy
). In other words, at the end of the full project deployment, users will see the same project information, in the same format as if they manually calledwebiny info
.12. Improved
webiny about
Command OutputThe
webiny about
command now also shows the following:13. Added
ProjectApplication
InterfaceI've created the
ProjectApplication
TS interface. Needed it mainly so that the DX is better when using the new CLI lifecycle event classes.14. Open Admin App Automatically On First Deploy
Once the initial full project deployment is done (via
webiny deploy
), the CLI will try to immediately open the Admin app in user's default browser. Below are the two images that show how it looks.15. Build Errors Printed Two Times (Frontend Apps)
Prior to this PR, if an error occurred while building a frontend app, the error would be printed twice.
This is no longer the case.
16. Throw Friendly Messages When Prematurely Deploying Applications
We've added checks that ensure API app cannot be deployed if Core wasn't deployed. The same goes with Admin: the app cannot be deployed if API wasn't deployed yet.
17. Deployment - Nicer Durations
Prior to this PR, durations would be printed in seconds, making them hard to read (e.g., a deployment finished in 654.542 seconds).
This is no longer the case. From now on, durations will be printed in minutes/seconds. For example:
Other
1. Using
wts
Package For TelemetryPrior to this PR, we've been issuing events to
t.webiny.com
via our own implementation (node-fetch
basically. With this PR, we've switched to usingwts
. An interesting side effect is that some code has been simplified, for example the oldsetProperties
function no longer exists, everything is done via a singlesendEvent
function call.2. Refactored Telemetry Package Code
Apart from the
wts
package mentioned above, we've also refactored existing telemetry package code.3. Remove
pbLegacyRenderingEngine
LeftoversA couple of occurrences of the
pbLegacyRenderingEngine
deploy hook plugin have been left hanging in the codebase. Those are no longer needed, so they have been fully cleaned up.4. WCP Badge In Admin App
When a Webiny project has been linked with WCP, in the Admin app, a small
WCP
badge will appear in the main menu, at the very bottom, where the Webiny version is printed.Note that, on hover, the WCP project ID will be shown to the user.
How Has This Been Tested?
Manual.
Documentation
Changelog.