-
Notifications
You must be signed in to change notification settings - Fork 481
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
RFC: Explore using a centralized script runner abstraction #1567
Comments
Great idea to me. This is a very similar idea that we did for portal with liferay-npm-scripts. The pain points are a little different, in portal we wanted to give ease of entry for backend devs and also wanted to avoid having to change every module's npm scripts whenever there was a sweeping change. For our case here, I think it definitely adds value to the project but I do slightly worry that its an over-abstraction for Clay's specific use case. Main reasons are that the breadth of Clay doesn't seem like it will grow uncontrollably(i.e. portal's modules), granted its easy to say its an over-abstraction now when there is a single package vs a year from now. Also most people working in this repo should have a frontend-bent in skills and having explicit npm scripts can be helpful. So needless to say, I am cool with going this direction and I am mostly just playing devils advocate in regards to our specific needs. |
node_modules
to correctly generate of the types
#2238
Seeing as this got mentioned recently, a couple of updates to my "prototype" since opening this issue back in February:
I changed this by splitting it into two tasks,
so it will try
I don't remember how I fixed this, but now it just works:
So at the time of writing the top-level scripts look like this:
and the package-level scripts ((sample)[https://github.com/wincent/js/blob/master/packages/throttle/package.json#L19-L31]) look like this:
|
Did we end up making a centralized script runner abstraction as a response to this issue, or did it just stay in the limbo? @wincent The referenced PR only mentions this issue, but wasn't meant to solve it. |
Nope. I mean, all the links I posted (to another project that takes the suggested approach) are valid, but we never did anything about it in Clay itself. |
@wincent should we revive this issue or close it? |
There is also a third option, which is do nothing. You folks who are working on Clay are in the best position to decide which of the three is best.
|
Alright, keeping it open so we know it's something we can work on when the time comes. |
Yeah I think its best to keep it around but not actively seek it out at the moment. |
This new private package is to the monorepo what liferay-npm-scripts is to the liferay-portal repo: that is, it presents a simplified interface over the top of some common operations (build, format, lint, test etc) that we can call from all over without having to pass complicated parameter lists. In terms of prior art, I did something similar in a monorepo over here a while back: https://github.com/wincent/js/tree/master/packages/workspace-scripts We talked about doing this in Clay, but never got around to it: liferay/clay#1567 The solution taken in Clay is to use a Yeoman generator to produce its 40+ packages. This makes creation easy, but not maintenance, because if you want to change what the scripts do, or what scripts there are, you have to touch every single package.json file. Hence, the alternate approach taken here. Why not just use liferay-npm-scripts, then? Well, that is currently very specifically tailored for use in liferay-portal (apart from some minor use for formatting in this repo and in the liferay-learn one), and there are some kinds of things we want to do in this repo that we'll never want to do in liferay-portal, as far as I know (eg. publishing npm packages). So, the plan then, is to continue investing in liferay-npm-scripts and making it more generally useful, but to have a specialized tool in this repo that calls liferay-npm-scripts whenever appropriate (you can already see this because our `format` task calls liferay-npm-scripts). Test plan: ran a bunch of commands; I don't know if I managed to run every command from every directory, but I did try to hit a good sample of them... added some `console.log()` to things I can't really run yet for real (like the `publish`) tasks to convince myself that they are probably going to work.
I think the |
@julien yeah, I also really like the idea of centralizing the build and maybe we could even cut the build time considerably. But I'm thinking now that since we want to centralize components in just one package maybe we don't need that anymore, I think we can close that for now but we can come back to that idea later if we change our minds about something. What do you think? |
@matuzalemsteles if we manage to get all components in on package, yes we probably don't need it, but I still think we can keep this issue around just to see how far we manage to go. |
There is a lot of discussion in #1548 about how to set up packages moving forward, but there is related opportunity that we could explore soon. Creating this separate RFC issue so as not to delay or derail that PR.
Objective
Explore using a centralized script runner abstraction so that we can easily run tasks at root or individual package level, and have painless updates as we evolve our task implementations.
Current set-up
One of the things the generator does is create a
package.json
from a template with a set of hard-coded build scripts:This is good because it means we don't have to stop and think about how to set up scripts for every package we create, nor do we risk copy-paste errors that could arise if we weren't using a generator to do the work for us.
However, just say we decide to change how we run the tests or do the build in the future, then every package's "package.json" needs to be updated.
RFC set-up
If we had an abstraction that knew how to do those "script" tasks, then we could use that instead of the individual tools (
babel
,tsc
,npm
,webpack-dev-server
,jest
etc). If the underlying individual tool changed, then we would just update our abstraction in one place and it would take effect in all the packages immediately without any need to edit the "package.json" files. Additionally, with an abstraction in place designed to work in a monorepo, we have a single location that we can imbue with knowledge about the structure of the project, to give it the "intelligence" necessary to work identically at the root level or within individual packages (the latter is something that @bryceosterhaus brought up as being important in that other PR).That's all very abstract, so what would this "abstraction" look like? I prototyped one way it could look like in a side project:
eslint
,tsc
etc.workspace-scripts format
,workspace-scripts lint
etc) (the only reason I haven't made them all into "workspace-scripts" calls is because I haven't done it yet).yarn lint
runs the lints for the whole repo.yarn workspace-scripts lint PACKAGE1 PACKAGE2...
to run the lints scoped to specific packages.workspace-scripts
: for example, the "test" script here is justworkspace-scripts test PACKAGE_NAME
.workspace-scripts test workspace-scripts
, it uses./bin/index.js test workspace-scripts
workspace-scripts build || make -j 4 all
, so it tries to use the built version if it can but it falls back if necessary.So that's all just a prototype, but it hopefully shows the idea that you can:
$TOOL $TASK $PACKAGE_NAME
.The text was updated successfully, but these errors were encountered: