Comments (4)
+1
from redux-cli.
Yeah this is totally doable!
First let me re-iterate the question to make sure I'm understanding what exactly you'd like to do:
When you run redux g dumb MyComponent
you want the MyComponent.test.js
file to live inside a __tests__
folder that is nested in the components
folder?
If so, to implement that you can override the default blueprints that come with the CLI and/or the starter kit. To do that you just need to create a local blueprints
folder in your project root OR modify a blueprint that is already in your project root (if using the starter kit). You would want to change the blueprint for dumb
to look like this:
1 dumb
2 ├── files
3 │ └── __root__
4 │ └── __dumb__
5 │ ├── __test__
6 │ │ └── __name__.test.js
7 │ └── __name__.js
8 └── index.js
Now we have a little bit of an issue because the __test__
token is going to be automatically converted to whatever your testBase
is. However, we can take advantage of the 'hooks' inside each blueprints index.js
to modify functionality. So inside the index.js
file for the dumb
blueprint you could do this:
module.exports = {
description() {
return 'Generates a dumb (aka Pure) component';
},
fileMapTokens() {
return {
__test__: (options) => {
return '__test__';
}
};
}
};
This essentially overrides the default behavior and says that when mapping the files to be generated leave the __test__
token alone and use the STRING '__test__'
for the folder name.
Hope this makes sense, let me know if you have any questions!
from redux-cli.
Hi Spencer,
Thanks, works like a charm! I had to add the path to __dumb__
compoents as well, like so:
module.exports = {
description() {
return 'Generates a dumb (aka Pure) component';
},
fileMapTokens() {
return {
__test__: (options) => '__tests__',
__dumb__: (options) => 'components',
};
}
};
👍
from redux-cli.
Awesome, glad you got it working!
from redux-cli.
Related Issues (20)
- Implement an in memory file system to use in testing HOT 1
- Boilerplates and the new command HOT 3
- blueprint options HOT 5
- config command for cli HOT 2
- copy or clone command for cli HOT 6
- Adding prompts to blueprints HOT 4
- fileMapToken refactoring HOT 8
- Chat channel? HOT 2
- 2.0 default blueprints HOT 4
- blueprint injection or rerendering HOT 6
- asset blueprints
- eslint quotes avoidEscape HOT 2
- validate command for cli
- eslint fails for blueprints/blueprint/files/blueprints/name/index.js HOT 9
- Documentation for 2.0
- Use template-literal instead of EJS HOT 3
- Multiple and Alternate Templating Engines
- does the world need blueprints when it has Hygen? HOT 12
- Typescript Support
- How to integrate React-Router (v4.0.0) in this Cli
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 redux-cli.