-
Notifications
You must be signed in to change notification settings - Fork 407
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
Basics of being dependent and passing in config #223
Basics of being dependent and passing in config #223
Conversation
@EvanLovely you are an open source juggernaut! Thanks for this work - I am feeling a bit overwhelmed by the support and interest of late, so I might be slow on reviewing everything. Please put up with me ⏳ |
Thanks! No worries. Hopefully I can help more soon as we use PatternLab pretty heavily at work. |
Hi @EvanLovely forgive my ignorance on this following issue... If this is accepted, creating the distinction between devDependencies and dependencies, won't a user pulling down patternlab node via ... thinking and googling ensues ... This is just now starting to click more for me! Ok. So really the "vanilla" documentation should be moe clear (this is more for my benefit than yours, FYI don't be offended 😊 ): DownloadYou may get Pattern Lab a couple ways, depending on your intended use: Stand-Alone Installation
Pattern Lab as a Dependency
Please let me know if I have this right. If I do, I'll accept this and get the cc @geoffp this might be of interest to you too. |
I think that putting out documentation on how to use this as a dependency is too early. Due to how the paths are set up in I also think that a Yeoman Generator would be the way to go for scaffolding out a "Stand-Alone Installation" – we could even ask questions like if they want Sass or not, Grunt or Gulp, etc and then create a different file structure based on those questions. Also, a good tidbit you may find useful for testing is the ability to supply different arguments to
or a shorthand for GitHub URLs:
Doing so and comparing to So basically what I'm saying is that I don't think anything needs to get added to the README: all dependencies will get installed with a |
Okay I finally get this. Your example code was useful, it wasn't clicking the first time through my head. Very happy to have you on board to help with thinking through this problem!
I like the idea in general, but at least at this time I want to keep Yeoman outside the scope of this repository. I think that could change as it matures more (or perhaps others focus on this), but right now my focus is this dependency work, pattern engines, and making things more modular/extensible...I believe others have already wrapped the project and are essentially doing this work, but I don't recall who or where at this time. I've wondered if my perspective toward Yeoman is skewed because I don't go through the motions/pain of initializing projects with the same frequency as those in client services. Thanks for the tips on testing. I've tested PRs locally for a while, but never tried |
It seems like the struggle here is against direct references to
The first one is completely unnecessary, the next two just need the debug flag, but don't have access to the main patternlab object, which is where the config data lives. The fourth I think is mixed, but the problem areas are just debug flag. The rest are unit tests that may not ever have access to the real patternlab object -- that's a challenge. Maybe we can cheat and create a global variable (not even sure how that works in Node, honestly) for the debug flag. And maybe we can just say that the unit tests only work in a standalone PL -- I personally only run them in a standalone copy. |
Also, I agree with @bmuenzenmeyer on Yeoman -- it's a fine tool where it works, and I'm not against code generation or scaffolding in general. But I think we're trying to aggressively reduce the number of moving parts and external dependencies needed to get up and running with PL to tear down barriers to use. |
I've started reading more of the node documentation to determine how best to do this, but yet I think it's possible to place this flag somewhere more intelligently. https://nodejs.org/api/modules.html |
It might be nice to be able to say something like: grunt serve --debug
gulp serve --debug rather than editing the config. |
Agreed
|
OK, lots to respond to here, so I'm going to do this in parts; first off @geoffp I'm not seeing those hard coded references to Here's the first few you mentioned and where I'm looking:
The only two references I can find to |
Alright, next up: I've just added a new commit to this PR. When references to This PR enables people to pass in a - patternlab.config = config || fs.readJSONSync('./config.json');
+ patternlab.config = config || fs.readJSONSync(path.resolve(__dirname, '../config.json')); I believe this pattern could be applied to other places and that would solve having change the working directory to the root of this repo before executing. |
@EvanLovely you're right, I think many of those are probably just in the pattern-engines branch, which is where I'm working at the moment. Can you address the ones in the pattern_assembler tests? This new approach makes me way less nervous than changing the working directory. |
Good to hear! I think the reference to Agreed on not like the approach on changing the working directory – that's why I suggested not documenting that method for others to follow. |
I checked this out and merged after a quick test. @geoffp and @EvanLovely - from your perspectives, what's left to address on this PR or #220? I am aware of #229 and will be taking that one |
It would be nice but not necessary to have a global variable for the debug flag. I'd like to try replacing my copy-the-config solution with this one today, if I can get to it, since I have a real-world NPMified configuration up and running. That should give us one more vote of confidence. |
It works for me! My gulpfile is much simpler without the fussy config file copy step, and everything seems to work. I guess all we need now is some documentation. @bmuenzenmeyer, feel free to assign me any work you need to get 1.1.0 out the door. I'm going to work on some of our internal toolchain stuff until I hear back. |
Great! @geoffp thanks for the offer of help with 1.1.0 - I definitely appreciate and welcome it. Could toy please take the README content stubbed out in #223 (comment) as a base and see if anything else is needed/requires change? |
On it. |
Okay -- I've gone through a "fresh install" from scratch and tried to piece together a fresh require()able copy of patlab, documenting each step I had to take. This is going to bring into focus why it's not quite yet a supported feature, if you know what I mean. 😀 But it should also tell us what we need to streamline to make it a better supported configuration. Full markdown coming up next. I have the .md stored on my machine as well, so I can hand it off properly if/when you want to publish these instructions. |
👍 @geoffp thanks so much! |
@EvanLovely, would you review this as well, please? EDIT: Forgot the create public dir. step. Installing and running Pattern Lab as an NPM dependencyNote: support for this configuration is still young, and is still being actively worked on. Expect a few bumps in the road and bear with us as we polish this up.
|
Hey, sorry for my lack of responses — was on a birthday ski vacation :) I'll check into this very soon; thanks!! |
OK, so here's the absolute basics of being able to
var pl = require('patternlab-node')(config);
. The big problem that remains is that most of the stuff that is ran frombuilder/patternlab.js
(therequire
-ed file) is running from the working directory ofnode_modules/patternlab-node/
, so this PR doesn't complete #221 but simply moves towards it and allows it to work if you know what you're doing. The way I'm getting around this (for now) is with this:This PR also creates the distinction between dependencies and devDependencies – if this is a required dependency in other projects, only the dependencies get installed; otherwise when
npm install
is ran here, both get installed.I expect this PR to be easy to merge and should not disrupt other workflows or uses and hopefully we can build upon this approach by making
builder/patternlab.js
run in the correct working directory (I believe it's a distinction betweenprocess.cwd()
and__dirname
, but I'd need to look closer to really know).🍻