-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11086 from chris-visser/feature/create-vue-app
- Loading branch information
Showing
24 changed files
with
349 additions
and
14 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
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 @@ | ||
node_modules/ |
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 @@ | ||
local |
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,24 @@ | ||
# Meteor packages used by this project, one per line. | ||
# Check this file (and the other files in this directory) into your repository. | ||
# | ||
# 'meteor add' and 'meteor remove' will edit this file for you, | ||
# but you can also edit it by hand. | ||
|
||
meteor-base # Packages every Meteor app needs to have | ||
mobile-experience # Packages for a great mobile UX | ||
mongo # The database Meteor supports right now | ||
reactive-var # Reactive variable for tracker | ||
|
||
standard-minifier-css # CSS minifier run for production mode | ||
standard-minifier-js # JS minifier run for production mode | ||
es5-shim # ECMAScript 5 compatibility for older browsers | ||
ecmascript # Enable ECMAScript2015+ syntax in app code | ||
typescript # Enable TypeScript syntax in .ts and .tsx modules | ||
shell-server # Server-side component of the `meteor shell` command | ||
|
||
tracker # Dependency tracker to allow reactive callbacks | ||
static-html # Define static page content in .html files | ||
akryum:vue-component # Vue-CLI template to publish components | ||
|
||
meteortesting:mocha # A package for writing and running your meteor app and package tests with mocha | ||
johanbrook:publication-collector # Test a Meteor publication by collecting its output |
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,2 @@ | ||
server | ||
browser |
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,23 @@ | ||
{ | ||
"name": "skel", | ||
"private": true, | ||
"scripts": { | ||
"start": "meteor run", | ||
"test": "meteor test --once --driver-package meteortesting:mocha", | ||
"test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha", | ||
"visualize": "meteor --production --extra-packages bundle-visualizer" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.8.3", | ||
"meteor-node-stubs": "^1.0.0", | ||
"vue": "^2.6.11", | ||
"vue-meteor-tracker": "^2.0.0-beta.5" | ||
}, | ||
"meteor": { | ||
"mainModule": { | ||
"client": "src/client.js", | ||
"server": "src/server.js" | ||
}, | ||
"testModule": "tests/main.js" | ||
} | ||
} |
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 @@ | ||
<template> | ||
<div> | ||
<h1>Welcome to Meteor!</h1> | ||
<hello/> | ||
<info/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Hello from './components/Hello.vue' | ||
import Info from './components/Info.vue' | ||
export default { | ||
components: { | ||
Hello, | ||
Info, | ||
}, | ||
} | ||
</script> | ||
|
||
<style> | ||
body { | ||
font-family: sans-serif; | ||
padding: 10px; | ||
} | ||
</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,12 @@ | ||
import Vue from 'vue' | ||
|
||
import './plugins' | ||
|
||
import App from './App.vue' | ||
|
||
Meteor.startup(() => { | ||
new Vue({ | ||
el: '#app', | ||
...App, | ||
}) | ||
}) |
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,3 @@ | ||
import { Mongo } from 'meteor/mongo'; | ||
|
||
export default new Mongo.Collection('links'); |
24 changes: 24 additions & 0 deletions
24
tools/static-assets/skel-vue/src/collections/Links.tests.js
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,24 @@ | ||
// Tests for the behavior of the links collection | ||
// | ||
// https://guide.meteor.com/testing.html | ||
|
||
import { Meteor } from 'meteor/meteor'; | ||
import { assert } from 'chai'; | ||
import Links from './links.js'; | ||
|
||
if (Meteor.isServer) { | ||
describe('links collection', function () { | ||
it('insert correctly', function () { | ||
const linkId = Links.insert({ | ||
title: 'meteor homepage', | ||
url: 'https://www.meteor.com', | ||
}); | ||
const added = Links.find({ _id: linkId }); | ||
const collectionName = added._getCollectionName(); | ||
const count = added.count(); | ||
|
||
assert.equal(collectionName, 'links'); | ||
assert.equal(count, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<div> | ||
<button @click="increment">Click Me</button> | ||
<p>You've pressed the button {{counter}} times.</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
counter: 0, | ||
} | ||
}, | ||
methods: { | ||
increment() { | ||
this.counter += 1 | ||
} | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
p { | ||
font-family: serif; | ||
} | ||
</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,55 @@ | ||
<template> | ||
<div> | ||
<h2>Learn Meteor!</h2> | ||
<ul> | ||
<li> | ||
<form class="info-link-add"> | ||
<input type="text" v-model="title" name="title" placeholder="Title" required> | ||
<input type="url" v-model="url" name="url" placeholder="Url" required> | ||
<input type="submit" name="submit" @click="submit($event)" value="Add new link"> | ||
</form> | ||
</li> | ||
<li v-for="link in links"><a :href="link.url" target="_blank">{{link.title}}</a></li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Links from '../collections/Links' | ||
export default { | ||
data() { | ||
return { | ||
title: "", | ||
url: "", | ||
} | ||
}, | ||
meteor: { | ||
$subscribe: { | ||
'links': [], | ||
}, | ||
links () { | ||
return Links.find({}) | ||
}, | ||
}, | ||
methods: { | ||
submit(event) { | ||
event.preventDefault() | ||
Meteor.call('createLink', this.title, this.url, (error) => { | ||
if (error) { | ||
alert(error.error) | ||
} else { | ||
this.title = '' | ||
this.url = '' | ||
} | ||
}) | ||
} | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
ul { | ||
font-family: monospace; | ||
} | ||
</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,32 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import Links from './collections/Links.js'; | ||
|
||
Meteor.startup(() => { | ||
// if the Links collection is empty | ||
if (Links.find().count() === 0) { | ||
const data = [ | ||
{ | ||
title: 'Do the Tutorial', | ||
url: 'https://www.meteor.com/try', | ||
createdAt: new Date(), | ||
}, | ||
{ | ||
title: 'Follow the Guide', | ||
url: 'http://guide.meteor.com', | ||
createdAt: new Date(), | ||
}, | ||
{ | ||
title: 'Read the Docs', | ||
url: 'https://docs.meteor.com', | ||
createdAt: new Date(), | ||
}, | ||
{ | ||
title: 'Discussions', | ||
url: 'https://forums.meteor.com', | ||
createdAt: new Date(), | ||
}, | ||
]; | ||
|
||
data.forEach(link => Links.insert(link)); | ||
} | ||
}); |
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 @@ | ||
<head> | ||
<title>skel</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
</body> |
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,16 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { check } from 'meteor/check'; | ||
import Links from '../collections/Links.js'; | ||
|
||
Meteor.methods({ | ||
'createLink'(title, url) { | ||
check(url, String); | ||
check(title, String); | ||
|
||
return Links.insert({ | ||
url, | ||
title, | ||
createdAt: new Date(), | ||
}); | ||
}, | ||
}); |
20 changes: 20 additions & 0 deletions
20
tools/static-assets/skel-vue/src/methods/createLink.tests.js
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,20 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { assert } from 'chai'; | ||
import Links from '../collections/Links.js'; | ||
import './methods.js'; | ||
|
||
if (Meteor.isServer) { | ||
describe('method: createLink', function () { | ||
beforeEach(function () { | ||
Links.remove({}); | ||
}); | ||
|
||
it('can add a new link', function () { | ||
const addLink = Meteor.server.method_handlers['createLink']; | ||
|
||
addLink.apply({}, ['meteor.com', 'https://www.meteor.com']); | ||
|
||
assert.equal(Links.find().count(), 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './createLink' |
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,4 @@ | ||
import Vue from 'vue' | ||
import VueMeteorTracker from 'vue-meteor-tracker' | ||
|
||
Vue.use(VueMeteorTracker) |
Oops, something went wrong.