Comments (10)
+1 for option 2. If they do run yeoman init
in a non-empty folder, we might as well just assume that they want to control what files should be overwritten as well. The only issue I see with this is that incompatibilities might occur, but I guess we can't blame yeoman for that - I'm just worried that the issues sections might have an increase in PEBKAC issues like these.
from generator.
Looking through our generators, it would appear that all of them will require warnOn
if we want to prompt people about replacing files. I can add this in today.
One limitation of this at present is that it will blanket warn on the replacement of all files or files of a specific type, but doesn't allow users to confirm which files get overwritten and which ones don't in a prompt form. e.g
Confirm: 'index.html' is about to be overwritten. Proceed? y/n
Confirm: 'main.js' is about to be overwritten. Proceed? y/n
The present behaviour instead will be that we warn before overwriting once and require you to pass the --force
flag if you wish to proceed.
@mklabs do you have any suggestions for how we might improve the experience by hooking into the prompts API? Ideally if we could get back a list of what is being overwritten that would be useful. I think you mentioned a _warns
array earlier on in our discussions :)
from generator.
I really like how this problem is handled in Rails generators. I definitely think we should try to implement something similar.
They have a nice file collision menu (actually coming from Thor API: https://github.com/wycats/thor/blob/master/lib/thor/shell/basic.rb#L221)
$ rails g assets foo
invoke coffee
identical app/assets/javascripts/foo.js.coffee
invoke scss
identical app/assets/stylesheets/foo.css.scss
$ # do some changes to foo.css.scss
$ rails g assets foo
invoke coffee
identical app/assets/javascripts/foo.js.coffee
invoke scss
conflict app/assets/stylesheets/foo.css.scss
Overwrite /Users/mk/test/rails/foo/app/assets/stylesheets/foo.css.scss? (enter "h" for help) [Ynaqdh] h
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
Overwrite /Users/mk/test/rails/foo/app/assets/stylesheets/foo.css.scss? (enter "h" for help) [Ynaqdh] Y
force app/assets/stylesheets/foo.css.scss
Basically, whenever a file is written and that a collision is detected, this file collision menu pops out with all these options. The differences output is also pretty handy.
from generator.
I like that. It provides pretty much flexibility for what I imagine are most developers expectations for overwrite/collision. Is there a way that we could build on top of warnOn
to achieve something similar?
from generator.
If we introduce this API, warnOn
might become obsolete. I don't know.
This file menu would be tied to the file system API provided in the generators API (write, copy, template methods etc.). And would show up only when we detect that a file is about to be overwritten and that this file is not identical.
We might be able to implement the differences output by checking out how it's done within mocha, it has a really nice diff feature.
from generator.
As we aren't on version 1.0 yet, I don't mind us deprecating warnOn
at some point if we're able to come up with something more robust. Do you imagine the API proposed would take a lot of effort? (just trying to balance the solutions we're discussing in email vs a more long-term sustainable option)
from generator.
https://github.com/visionmedia/mocha/blob/master/lib/reporters/base.js#L318-352 :) (for future references if we want to provide the same diff output)
It's not trivial for sure, but I don't feel it's that difficult to implement, or at least take a try and see how it goes.
Complexity relies in being able to catch any file writes that might happen, this include overwrites that might be done using the remote API, or full directory copy.
from generator.
Thats pretty sexy! Glad to hear that you don't feel a better API would be overly difficult to implement.
As we've had quite a few developers asking about generator overwrites recently, I wouldn't mind us just landing something slightly better using either the current warnOn
updates (or something similar to the path-specific notices we discussed) for 0.9.1 with a view to a much better file API coming in a future 0.9.x release.
from generator.
We've now got 7a7dbc6 which is the first step towards solving the issues discussed. These will be going into 0.9.1, which we'll be releasing on Friday.
from generator.
@mklabs I really like your suggested solution. Sounds like a super solid one if done right. Lets do it after 1.0!
from generator.
Related Issues (20)
- Minimist CVE HOT 1
- "Which type of client-side component to create?" is missing "Extension" HOT 1
- Introduce a flag to use config in proxymode HOT 1
- Is this project abandoned? HOT 1
- Dependent library tui-jsdoc-template has high severity vulnerabilities HOT 1
- Value from option defined in a composed generator is only available on generator triggered HOT 2
- "Invoke validation failed. User forbidden to perform action" when trigger "More details" button of message extension sample HOT 2
- Cannot Remove Default Add-In HOT 2
- [deps] Check for breaking changes in Dependabot's PRs HOT 1
- Can't install 6.0.1 using npm HOT 5
- Improve readability of fs.test.ts; correct TS problems in it.
- Migrate tests to vitest and add node 20 to ci
- Replace jsdoc with typescript based documentation generator
- Dependency Conflict on `mem-fs` for yeoman-generator 7.x HOT 8
- yeoman-generator should declare an ordinary dependency on 'mem-fs' HOT 3
- Documentation is out of date HOT 2
- yeoman-generator wants conflicting transitive dependencies on mem-fs HOT 3
- How to compose generators in our own ESM-based generator HOT 8
- different document HOT 1
- issue with spawnCommandSync and (linux) mount during generator run HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator.