-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ Add new scaffolding tool The tool is called Hygen, and we can use it to automate file creations in Homeday Blocks. * ♻️ Remove unneeded fallback path in test.ejs.t * ♻️ Remove unexisting attribute in Hygen help command
- Loading branch information
Showing
13 changed files
with
607 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
inject: true | ||
before: "Services" | ||
eof_last: false | ||
skip_if: <%= name %> | ||
to: main.js | ||
--- | ||
export { default as <%= name %> } from './src/<%= path %>/<%= name %>.vue'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const path = require('path'); | ||
const _ = require('lodash'); | ||
|
||
module.exports = [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: "What's your component name?", | ||
validate(value) { | ||
if (!value.length) { | ||
return 'Components must have a name.'; | ||
} | ||
const fileName = _.kebabCase(value); | ||
if (fileName.indexOf('-') === -1) { | ||
return 'Component names should contain at least two words to avoid conflicts with existing and future HTML elements.'; | ||
} | ||
return true; | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'path', | ||
message: "The path to the component? (default: 'components')", | ||
initial: 'components', | ||
result: value => path.normalize(value), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
to: src/stories/<%= name %>.stories.js | ||
--- | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { storiesOf } from '@storybook/vue'; | ||
import { <%= name %> } from 'homeday-blocks'; | ||
|
||
const stories = storiesOf('Components|<%= name %>', module); | ||
|
||
stories.add('Default', () => ({ | ||
components: { <%= name %> }, | ||
template: ` | ||
<<%= name %> /> | ||
`, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
to: tests/unit/<%= path %>/<%= name %>.spec.js | ||
--- | ||
import { wrapperFactoryBuilder } from 'tests/unit/helpers'; | ||
import <%= name %> from '@/<%= path %>/<%= name %>.vue'; | ||
|
||
const wrapperBuilder = wrapperFactoryBuilder(<%= name %>); | ||
|
||
describe('<%= name %>', () => { | ||
const build = (overrideProps = {}) => { | ||
const props = { | ||
...overrideProps, | ||
}; | ||
|
||
const wrapper = wrapperBuilder({ props }); | ||
|
||
return { | ||
wrapper, | ||
}; | ||
}; | ||
|
||
it('should render', () => { | ||
const { wrapper } = build(); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
to: src/<%= path %>/<%= name %>.vue | ||
--- | ||
<template> | ||
<div> | ||
Your new awesome component: <%= name %> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: '<%= name %>', | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import 'homeday-blocks/src/styles/mixins.scss'; | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
message: | | ||
- hygen new {bold component} --name [NAME] --path [PATH] (default: components) | ||
- hygen new {bold service} --name [NAME] | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
inject: true | ||
append: true | ||
skip_if: <%= name %> | ||
to: main.js | ||
--- | ||
export { default as <%= h.changeCase.camel(name) %>Service } from './src/services/<%= name %>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: "What's your service name?", | ||
validate(value) { | ||
if (!value.length) { | ||
return 'A service must have a name.'; | ||
} | ||
return true; | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
to: src/services/<%= name %>.js | ||
--- | ||
export const myMethod = () => true; | ||
|
||
export default { | ||
myMethod, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
to: tests/unit/services/<%= name %>.spec.js | ||
--- | ||
import { myMethod } from '@/services/<%= name %>'; | ||
|
||
describe('<%= h.changeCase.camel(name) %> service', () => { | ||
it('works', () => { | ||
expect(myMethod()).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.