-
Notifications
You must be signed in to change notification settings - Fork 56
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
Restructure Repository to streamline development & releasing #25
Conversation
This looks great to me, i am able to run it by just using
|
We can probably change it to just
Sure! The tl;dr is:
Note that steps 2 and 3 can be handled using a GitHub Action that creates PRs for you (see this one for an example) that you just merge whenever you want to release, and the action will perform everything for you (including the publishing.) Setting this up is recommended (because it's so convenient), but entirely optional. In fact, if you're new to changesets, I'd recommend doing a couple of releases manually (as described above), so you understand how changesets ticks, before automating them. Let me know if you have more questions! |
Addendum to the release process: it's important to note that you can still do releases the old-fashioned way (with the new updates in this PR, essentially |
I've made the change you requested about moving the package into a top-level |
I've also added a GH action configuration for the changesets stuff. When merged, this will start creating release PRs as soon as new changesets are added to the repository, but it will never publish anything without your action. (It wouldn't be able to, anyway, since it doesn't have an NPM token yet.) But it'll be a good opportunity to look at what these things look like. |
Introduction & Important Notes
This is a big PR that changes a lot of things around in both the repository itself, and also in how the package is built. It implements a setup that I've been successfully using in my projects and been recommending to others, and is meant to be read as primarily a suggestion. There's a lot of stuff going on and I would understand 100% if you decide against adopting this; but do give it a try and see if it would work for you. If you have questions, I'd be happy to answer them.
First and foremost, this PR makes three major changes to the project:
preconstruct dev
task that will wire up all the different workspaces that internally depend on each other (like the examples apps depend on the CSM package) to make any kind of manual linking unnecessary; in fact it even does this in a way that workspaces can consume packages' Typescript sources (so you don't even need to run ayarn watch
or similar task. You can just write code and immediately get type warnings, HMR, the works. It's great!)changeset version
script will accumulate all these into updatedCHANGELOG.md
files, andchangeset publish
will publish changed packages to NPM. You can even set up a GitHub Action that will do all of these for you by way of automated Pull Requests -- just merge and it'll publish. It's really convenient.Development
One of the benefits all this provides is that hacking on the code now just requires these three steps:
yarn install
yarn dev
The last step will fire up the
waves
example, and you can immediately start making changes to the CSM package's TypeScript code with reloading, HMR, and so on.Releasing
Given at least one unreleased changeset in the repository, the process is now the following:
yarn changeset version
-- this will accumulate the unreleased changesets into updated CHANGELOG files and ask you to commit these changes (after review.)yarn release
-- this will run theyarn ci
task (which does integrity tests and builds the package) followed bychangeset publish
, which will publish the new version you created in the previous step to NPM.All of this can be wrapped in a GitHub action that I'd be happy to set up in a separate PR.
Caveats
vanilla
entry points is now based on a different configuration from before; Preconstruct uses thesub-package
approach for these for maximum compatibility; before, the package was using the new-ish package.json exports feature. Preconstruct is opinionated in this regard and can probably not reconfigured to use another approach, but the approach it's chosen has proven to be very reliable in the past. From where I'm standing, I don't see an issue with this switch, but YMMV.src
folder. I solved this by customizing each CRA apps' configuration through craco. I wish this hadn't been necessary, but it was the most pragmatic way forward. Please keep in mind that this is only necessary for the local development mode, it does not affect regular CSM usage in CRA apps.Other minor changes:
manypkg
to quickly identify and fix inconsistencies in the version requirements across the different example applications and packagesyarn ci
task that performs a bunch of integrity tests and builds all packages (if we ever get tests, we can add them here)yarn release
task that will perform theci
task followed bychangeset publish
.README.md
andLICENSE.md
into the package workspace, but symlinks both into the project root.stackblitz
configuration inpackage.json
to make SB fire up an example on startupyarn ci
script mentioned aboveyarn cache
action for faster runtimesTodo:
master
)