-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat(create-cycle-app): support motorcycle and ava #45
Conversation
Select core cycle lib and test runner. Adds infrastructure for passing multiple libs and use of templating.
Fix lint and other small errors
Note, I was not able to test it locally.
Please advice |
Hi @kristianmandrup, thanks for you contribution! I'll leave some comments as we discuss about this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an awesome addition to CCA, @kristianmandrup, but it will be easier to get these changes merged with smaller (and well discussed) PR's.
@@ -1,3 +1,14 @@ | |||
# v2.1.0 (2016-11-28) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't the need to change the CHANGELOG.md (as counter-intuitive as this seems), because it is updated by the release pipeline. So please, remove this change.
if (flavor) { | ||
// Ask just for the stream library | ||
inquirer.prompt([streamLibQuestion]).then(function (answers) { | ||
preparePackageJson(appFolder, appName, flavor, answers.streamLib, verbose) | ||
inquirer.prompt([cycleCoreLib, streamLibQuestion, testLibQuestion]).then(function (answers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked this idea, but considering the philosophy of CCA (one of the key points is the focus for beginners), we prefer to keep things simple and small, so, I'll ask you to put this changes around test library choices in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm, although a nice idea testLibQuestion
I'm not sure I see this as something that should be part of CCA
as is not an option related to cycle itself (while the others definitely support diversity
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why have a test lib at all? where to draw the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a very good question. Considering recent efforts made by @Widdershin on https://github.com/cyclejs/time, we could consider expanding the default tests examples, showing the basics of how to test cycle components (at least for the current "Hello world" component)
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "create-cycle-app", | |||
"version": "2.0.0", | |||
"version": "2.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't need to change the number, as release pipeline update it too.
@@ -19,6 +19,7 @@ | |||
"cycle-scripts": "./index.js" | |||
}, | |||
"dependencies": { | |||
"ava": "^0.17", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I think that you are hardcoding ava as a dependency, like mocha. As your proposal is to make this configurable, we should consider remove the hard-dependency and make them peerDependencies, and install the lib choosed by the user together with other dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I saw no other easy way to add ava with current very inflexible architecture, besides creating a set of new duplicate projects for all combinations. Hardly the way to go about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You see inflexibility where I see openness. There isn't the need to duplicate each core flavor, because you could create new ones and publish them on npm independently.
Each cycle-scripts-*
you see here, could be copied into motorcycle-scripts-*
(or forked) and customized for motorcycle (you could just ignore cycle-specific options on init script). There you could change test libs, template files and everything else you see suitable as motorcycle defaults.
I'm not rejecting changes on the tool, I'm just arguing that there's easier ways to achieve the same results without bloating the core tool and flavors.
Ok, so, I see 4 valuable proposals until now:
- Including
@cycle/isolate
as a default dependency - Adding motorcycle flavors
- Making the test library/tool an option
- Templating files
My proposal is that we turn each of this points into issues and build them progressively. What do you think?
@@ -27,6 +28,7 @@ | |||
"chalk": "^1.1.3", | |||
"cross-spawn": "^4.0.2", | |||
"dotenv": "^2.0.0", | |||
"ejs": "^2.5.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot agree with this in any manner. Installing a devDependency on the user's project just to render one example test file?
No, I think that this could be solved with two files and a single if
inside init script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know how else to add it. I didn't quite understand your nested projects infrastructure. Maybe you could document how to add the tools to do the work?
I've never seen anything quite like it. Loads of duplication to maintain in this way...
I always just have a single set of project templates... I developed dozens of similar generators in the past and never had to resort to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that adding some more contribution docs would be really helpful.
BTW there is one question to be made: "Is this dependency used only to create the project or it's a project dependency itself?"
When is the first case, we should find simple (hacky) ways to do it on init scripts. Otherwise, it's a dependency.
Each flavor' dependency becomes a devDependency when the project is "ejected", so, if the dependency would be put in devDependencies on a normal project, it must be on flavor dependencies.
cycle: ['@cycle/dom', 'xstream'], | ||
motorcycle: ['@motorcycle/core', '@motorcycle/dom'] | ||
} | ||
var extras = ['immutable', '@cycle/isolate'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what's the point in installing immutable by default? @cycle/isolate
seems to be a recurrent case, so, this could be included on all flavors in a proper PR, but immutable seems too opinionated to be in the core flavors.
Usually I prefer to use ramda
, that is a totally different lib, but serves me for similar cases. But again, this is my preference, not the end-user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 on including @cycle/isolate
.
Agree that immutable
should still a user choice and a default of a core-flavor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good
var ownPackageName = require(path.join(__dirname, '..', 'package.json')).name | ||
var ownPath = path.join(appPath, 'node_modules', ownPackageName) | ||
var appPackageJson = path.join(appPath, 'package.json') | ||
var appPackage = require(appPackageJson) | ||
|
||
if (libs.test === 'ava') { | ||
appPackage.ava = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another way to pass this parameters to the test runner? If possible, we should avoid polluting package.json with configuration that could be kept inside the cycle-scripts-*
and put them only after eject.
@kristianmandrup About the tests, you could run it with:
|
Hi geovani, Haha ;) About the tests, I just thought about that as well... About ava, not from what I can see in the docs and my own experience. Any Immutable seems to be a common choice for motorcycle in the example apps I have seen. Could be a confirm question or in a list of common extra libs choices? I also like Ramda, in fact I've recently been looking into Ideally the package.json etc. could/should be created via EJS templates, and not the current hacky patching strategy IMO. You are free to make whatever changes to my contribution that you like. |
Your welcome. All these questions are valuable... for discussion with the community and small PR's. I don't know ava, nor it's advantages against mocha, so, I would like to discuss this in another PR if possible. If immutable is a common choice, it's likely that users will immediately install it after creating the project (like isolate, that is a even more common lib), like the current approach, that wasn't reported as a problem. But I'm certain that I could be wrong, so, discuss this with community is even more valuable, both for motorcycle and cycle flavors. I still don't see the advantage in using a template engine to render 3 or 4 files. It's hacky, absolutely, and I'm still troubled with two This was a thought decision since the day-one. I came to the conclusion that including a template system, plus a extensive question-answer interface, would not differ from existing tools, like yeoman, e.g. Why don't use a yeoman generator then? There already have generators for cycle. Why not create a even more customizable and opinionated tool? There already are one. Each one (including CCA) has it's own approach to reach the same goal: help developers in getting the project setup quickly. The approach here is more simplistic and concise, but we let all doors open for contribution (there is an automatic discovery system for community flavors). If the goal was add every tool that we find useful on a large scale, thousand-lines project, we would bloat each "hello world" project with hundreds of MB of dependencies that could end not be used at all. Cycle's philosophy (at least, from my point of view), favors composition and incremental enhancement. Why it's tools should differ from this? |
As @geovanisouza92 mentioned and as we added in the |
Closing this. |
npm test
for the package I'm modifyingnpm run commit
instead ofgit commit
Select core cycle lib and test runner. Adds infrastructure for passing multiple libs and use of
templating.