-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add ui:create:vue command (#11)
- Loading branch information
Showing
18 changed files
with
431 additions
and
118 deletions.
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,15 @@ | ||
import {expect, test} from '@oclif/test'; | ||
|
||
describe('ui:create:vue', () => { | ||
test | ||
.command(['ui:create:vue']) | ||
.catch((ctx) => { | ||
expect(ctx.message).to.contain('Missing 1 required arg:'); | ||
}) | ||
.it('requires application name argument'); | ||
|
||
test | ||
.command(['ui:create:vue', 'myapp', '--preset', 'invalidPreset']) | ||
.catch('Unable to load preset') | ||
.it('requires a valid preset flag'); | ||
}); |
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,34 @@ | ||
import {EventEmitter} from 'events'; | ||
import {ChildProcess} from 'child_process'; | ||
import {spawnProcess} from './process'; | ||
|
||
jest.mock('child_process', () => ({ | ||
spawn: jest | ||
.fn() | ||
.mockImplementationOnce(() => { | ||
const emitter = new EventEmitter(); | ||
process.nextTick(() => emitter.emit('close', 0)); | ||
return emitter as ChildProcess; | ||
}) | ||
.mockImplementationOnce(() => { | ||
const emitter = new EventEmitter(); | ||
process.nextTick(() => emitter.emit('close', 1)); | ||
return emitter as ChildProcess; | ||
}), | ||
})); | ||
|
||
describe('spawnProcess', () => { | ||
it('should resolves with a success exit code', () => { | ||
const command = 'some valid command'; | ||
const args = ['-valid', 'option']; | ||
|
||
return expect(spawnProcess(command, args)).resolves.toEqual(0); | ||
}); | ||
|
||
it('should reject', () => { | ||
const command = 'invalid commande'; | ||
const args = ['-foo', 'bar']; | ||
|
||
return expect(spawnProcess(command, args)).rejects.toEqual(1); | ||
}); | ||
}); |
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
75 changes: 17 additions & 58 deletions
75
packages/vue-cli-plugin-coveo/generator/template/src/App.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 |
---|---|---|
@@ -1,73 +1,32 @@ | ||
<template> | ||
<div id="app" class="has-text-left container"> | ||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.3.45/css/materialdesignicons.min.css" /> | ||
<section class="box my-3"> | ||
<div class="columns"> | ||
<div class="column is-four-fifths"> | ||
<SearchBox /> | ||
</div> | ||
<div class="column"> | ||
<Facets /> | ||
</div> | ||
</div> | ||
<Summary /> | ||
</section> | ||
|
||
<section class="box my-3"> | ||
<div class="columns"> | ||
<div class="column"> | ||
<ResultList /> | ||
</div> | ||
</div> | ||
</section> | ||
<section class="box my-3"> | ||
<div class="columns"> | ||
<div class="column"> | ||
<Pager /> | ||
</div> | ||
</div> | ||
</section> | ||
<div id="app"> | ||
<div class="hero is-primary is-medium"> | ||
<Hero msg="Welcome to Your Coveo Vue.js Search Page" /> | ||
</div> | ||
<SearchPage /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Vue from 'vue'; | ||
import Buefy from 'buefy'; | ||
import 'buefy/dist/buefy.css'; | ||
import 'material-design-icons'; | ||
import ResultList from './components/ResultList.vue'; | ||
import SearchBox from './components/SearchBox.vue'; | ||
import Facets from './components/Facets.vue'; | ||
import Summary from './components/Summary.vue'; | ||
import Pager from './components/Pager.vue'; | ||
import engine from './Engine'; | ||
import { AnalyticsActions, SearchActions } from '@coveo/headless'; | ||
Vue.use(Buefy); | ||
<script lang="ts"> | ||
import { Component, Vue } from 'vue-property-decorator'; | ||
import Hero from './components/Hero.vue'; | ||
import SearchPage from './components/SearchPage.vue'; | ||
export default { | ||
name: 'App', | ||
@Component({ | ||
components: { | ||
ResultList, | ||
SearchBox, | ||
Facets, | ||
Summary, | ||
Pager, | ||
}, | ||
mounted: function() { | ||
this.$nextTick(function() { | ||
engine.dispatch(SearchActions.executeSearch(AnalyticsActions.logInterfaceLoad())); | ||
}); | ||
Hero, | ||
SearchPage, | ||
}, | ||
}; | ||
}) | ||
export default class App extends Vue {} | ||
</script> | ||
|
||
<style> | ||
<style lang="scss"> | ||
#app { | ||
font-family: Avenir, Helvetica, Arial, sans-serif; | ||
font-family: $family-primary; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-align: center; | ||
color: #2c3e50; | ||
margin-top: 60px; | ||
color: $primary !important; | ||
} | ||
</style> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 18 additions & 14 deletions
32
packages/vue-cli-plugin-coveo/generator/template/src/components/Facet.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 |
---|---|---|
@@ -1,46 +1,50 @@ | ||
<template> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<p class="card-header-title">{{ this.title }}</p> | ||
</div> | ||
<div class="card-content"> | ||
<div class="mb-5"> | ||
<p class="is-size-5 mb-4">{{ this.title }}</p> | ||
<div class="content"> | ||
<ul v-on:toggle="onToggle"> | ||
<FacetValue | ||
@toggle="onToggle" | ||
v-for="v in state.values" | ||
v-bind:key="v.value" | ||
v-bind:facetValue="v" /> | ||
v-bind:facetValue="v" | ||
/> | ||
</ul> | ||
</div> | ||
<div class="card-footer"></div> | ||
</div> | ||
</template> | ||
<script> | ||
import { buildFacet } from '@coveo/headless'; | ||
import {buildFacet} from '@coveo/headless'; | ||
import FacetValue from './FacetValue'; | ||
import engine from '../Engine'; | ||
export default { | ||
name: 'Facet', | ||
props: ['field', 'title'], | ||
components: { FacetValue }, | ||
data: function() { | ||
components: {FacetValue}, | ||
data: function () { | ||
return { | ||
state: {}, | ||
}; | ||
}, | ||
methods: { | ||
onToggle: function(facetValue) { | ||
onToggle: function (facetValue) { | ||
this.facet.toggleSelect(facetValue); | ||
}, | ||
}, | ||
created: function() { | ||
created: function () { | ||
this.facet = buildFacet(engine, { | ||
options: { field: this.field, title: this.title }, | ||
options: {field: this.field, title: this.title}, | ||
}); | ||
this.facet.subscribe(() => { | ||
this.state = { ...this.facet.state }; | ||
this.state = {...this.facet.state}; | ||
}); | ||
}, | ||
}; | ||
</script> | ||
<style scoped> | ||
.content ul { | ||
list-style-type: none; | ||
margin: 0; | ||
} | ||
</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
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
Oops, something went wrong.