first commit
This commit is contained in:
31
ui/generators/new/component/component.ejs.t
Normal file
31
ui/generators/new/component/component.ejs.t
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
to: "src/components/<%= h.changeCase.kebab(name).toLowerCase().slice(0, 5) === 'base-' ? '_' : '' %><%= h.changeCase.kebab(name) %>.vue"
|
||||
---
|
||||
<%
|
||||
if (blocks.indexOf('script') !== -1) {
|
||||
%><script>
|
||||
export default {
|
||||
<% if (blocks.indexOf('template') === -1) {
|
||||
%>render(h) {
|
||||
return <div/>
|
||||
}<% } %>
|
||||
}
|
||||
</script>
|
||||
<%
|
||||
}
|
||||
|
||||
if (blocks.indexOf('template') !== -1) {
|
||||
%>
|
||||
<template>
|
||||
<div/>
|
||||
</template>
|
||||
<%
|
||||
}
|
||||
|
||||
if (blocks.indexOf('style') !== -1) {
|
||||
%>
|
||||
<style lang="scss" module>
|
||||
@import '@design';
|
||||
</style><%
|
||||
}
|
||||
%>
|
||||
45
ui/generators/new/component/prompt.js
Normal file
45
ui/generators/new/component/prompt.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: '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: 'multiselect',
|
||||
name: 'blocks',
|
||||
message: 'Blocks:',
|
||||
initial: ['script', 'template', 'style'],
|
||||
choices: [
|
||||
{
|
||||
name: 'script',
|
||||
message: '<script>',
|
||||
},
|
||||
{
|
||||
name: 'template',
|
||||
message: '<template>',
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
message: '<style>',
|
||||
},
|
||||
],
|
||||
validate(value) {
|
||||
if (value.indexOf('script') === -1 && value.indexOf('template') === -1) {
|
||||
return 'Components require at least a <script> or <template> tag.'
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
]
|
||||
16
ui/generators/new/component/unit.ejs.t
Normal file
16
ui/generators/new/component/unit.ejs.t
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
to: "src/components/<%= h.changeCase.kebab(name).toLowerCase().slice(0, 5) === 'base-' ? '_' : '' %><%= h.changeCase.kebab(name) %>.unit.js"
|
||||
---
|
||||
<%
|
||||
let fileName = h.changeCase.kebab(name).toLowerCase()
|
||||
const importName = h.changeCase.pascal(fileName)
|
||||
if (fileName.slice(0, 5) === 'base-') {
|
||||
fileName = '_' + fileName
|
||||
}
|
||||
%>import <%= importName %> from './<%= fileName %>'
|
||||
|
||||
describe('@components/<%= fileName %>', () => {
|
||||
it('exports a valid component', () => {
|
||||
expect(<%= importName %>).toBeAComponent()
|
||||
})
|
||||
})
|
||||
6
ui/generators/new/e2e/e2e.ejs.t
Normal file
6
ui/generators/new/e2e/e2e.ejs.t
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
to: tests/e2e/specs/<%= h.changeCase.kebab(name) %>.e2e.js
|
||||
---
|
||||
describe('<%= h.changeCase.pascal(name) %>', () => {
|
||||
|
||||
})
|
||||
13
ui/generators/new/e2e/prompt.js
Normal file
13
ui/generators/new/e2e/prompt.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Name:',
|
||||
validate(value) {
|
||||
if (!value.length) {
|
||||
return 'Components must have a name.'
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
]
|
||||
18
ui/generators/new/layout/layout.ejs.t
Normal file
18
ui/generators/new/layout/layout.ejs.t
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
to: "src/router/layouts/<%= h.changeCase.kebab(name) %>.vue"
|
||||
---
|
||||
<template>
|
||||
<div :class="$style.container">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" module>
|
||||
@import '@design';
|
||||
|
||||
.container {
|
||||
min-width: $size-content-width-min;
|
||||
max-width: $size-content-width-max;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
13
ui/generators/new/layout/prompt.js
Normal file
13
ui/generators/new/layout/prompt.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Name:',
|
||||
validate(value) {
|
||||
if (!value.length) {
|
||||
return 'Layout components must have a name.'
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
]
|
||||
19
ui/generators/new/layout/unit.ejs.t
Normal file
19
ui/generators/new/layout/unit.ejs.t
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
to: "src/router/layouts/<%= h.changeCase.kebab(name) %>.unit.js"
|
||||
---
|
||||
<%
|
||||
const fileName = h.changeCase.kebab(name)
|
||||
const importName = h.changeCase.pascal(fileName) + 'Layout'
|
||||
%>import <%= importName %> from './<%= fileName %>'
|
||||
|
||||
describe('@layouts/<%= fileName %>', () => {
|
||||
it('renders its content', () => {
|
||||
const slotContent = '<p>Hello!</p>'
|
||||
const { element } = shallowMount(<%= importName %>, {
|
||||
slots: {
|
||||
default: slotContent,
|
||||
},
|
||||
})
|
||||
expect(element.innerHTML).toContain(slotContent)
|
||||
})
|
||||
})
|
||||
10
ui/generators/new/module/module.ejs.t
Normal file
10
ui/generators/new/module/module.ejs.t
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
to: src/state/modules/<%= h.changeCase.kebab(name) %>.js
|
||||
---
|
||||
export const state = {}
|
||||
|
||||
export const getters = {}
|
||||
|
||||
export const mutations = {}
|
||||
|
||||
export const actions = {}
|
||||
13
ui/generators/new/module/prompt.js
Normal file
13
ui/generators/new/module/prompt.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Name:',
|
||||
validate(value) {
|
||||
if (!value.length) {
|
||||
return 'Vuex modules must have a name.'
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
]
|
||||
13
ui/generators/new/module/unit.ejs.t
Normal file
13
ui/generators/new/module/unit.ejs.t
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
to: src/state/modules/<%= h.changeCase.kebab(name) %>.unit.js
|
||||
---
|
||||
<%
|
||||
const fileName = h.changeCase.kebab(name)
|
||||
const importName = h.changeCase.camel(fileName) + 'Module'
|
||||
%>import * as <%= importName %> from './<%= fileName %>'
|
||||
|
||||
describe('@state/modules/<%= fileName %>', () => {
|
||||
it('exports a valid Vuex module', () => {
|
||||
expect(<%= importName %>).toBeAVuexModule()
|
||||
})
|
||||
})
|
||||
13
ui/generators/new/util/prompt.js
Normal file
13
ui/generators/new/util/prompt.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Name:',
|
||||
validate(value) {
|
||||
if (!value.length) {
|
||||
return 'Utility functions must have a name.'
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
]
|
||||
14
ui/generators/new/util/unit.ejs.t
Normal file
14
ui/generators/new/util/unit.ejs.t
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
to: "src/utils/<%= h.changeCase.kebab(name) %>.unit.js"
|
||||
---
|
||||
<%
|
||||
const fileName = h.changeCase.kebab(name)
|
||||
const importName = h.changeCase.camel(fileName)
|
||||
%>import <%= importName %> from './<%= fileName %>'
|
||||
|
||||
describe('@utils/<%= fileName %>', () => {
|
||||
it('says hello', () => {
|
||||
const result = <%= importName %>()
|
||||
expect(result).toEqual('hello')
|
||||
})
|
||||
})
|
||||
9
ui/generators/new/util/util.ejs.t
Normal file
9
ui/generators/new/util/util.ejs.t
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
to: "src/utils/<%= h.changeCase.kebab(name) %>.js"
|
||||
---
|
||||
<%
|
||||
const fileName = h.changeCase.kebab(name)
|
||||
const importName = h.changeCase.camel(fileName)
|
||||
%>export default function <%= importName %>() {
|
||||
return 'hello'
|
||||
}
|
||||
18
ui/generators/new/view/prompt.js
Normal file
18
ui/generators/new/view/prompt.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Name:',
|
||||
validate(value) {
|
||||
if (!value.length) {
|
||||
return 'View components must have a name.'
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'useStyles',
|
||||
message: 'Add <style> block?',
|
||||
},
|
||||
]
|
||||
13
ui/generators/new/view/unit.ejs.t
Normal file
13
ui/generators/new/view/unit.ejs.t
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
to: "src/router/views/<%= h.changeCase.kebab(name) %>.unit.js"
|
||||
---
|
||||
<%
|
||||
const fileName = h.changeCase.kebab(name)
|
||||
const importName = h.changeCase.pascal(fileName)
|
||||
%>import <%= importName %> from './<%= fileName %>'
|
||||
|
||||
describe('@views/<%= fileName %>', () => {
|
||||
it('is a valid view', () => {
|
||||
expect(<%= importName %>).toBeAViewComponent()
|
||||
})
|
||||
})
|
||||
31
ui/generators/new/view/view.ejs.t
Normal file
31
ui/generators/new/view/view.ejs.t
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
to: "src/router/views/<%= h.changeCase.kebab(name) %>.vue"
|
||||
---
|
||||
<%
|
||||
const fileName = h.changeCase.kebab(name)
|
||||
const importName = h.changeCase.pascal(fileName)
|
||||
const titleName = h.changeCase.title(name)
|
||||
%><script>
|
||||
import Layout from '@layouts/main.vue'
|
||||
|
||||
export default {
|
||||
page: {
|
||||
title: '<%= titleName %>',
|
||||
meta: [{ name: 'description', content: 'The <%= titleName %> page.' }],
|
||||
},
|
||||
components: { Layout }
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Layout>
|
||||
<%= titleName %>
|
||||
</Layout>
|
||||
</template>
|
||||
<%
|
||||
|
||||
if (useStyles) { %>
|
||||
<style lang="scss" module>
|
||||
@import '@design';
|
||||
</style>
|
||||
<% } %>
|
||||
Reference in New Issue
Block a user