燕鹏 4 роки тому
коміт
6fe91b36d5
  1. 50
      .docker/Dockerfile
  2. 2
      .gitignore
  3. 19
      .meteor/.finished-upgraders
  4. 1
      .meteor/.gitignore
  5. 7
      .meteor/.id
  6. 24
      .meteor/packages
  7. 2
      .meteor/platforms
  8. 1
      .meteor/release
  9. 78
      .meteor/versions
  10. 7
      client/main.html
  11. 12
      client/main.js
  12. 3
      imports/api/collections/Links.js
  13. 24
      imports/api/collections/Links.tests.js
  14. 32
      imports/api/fixtures.js
  15. 16
      imports/api/methods/createLink.js
  16. 20
      imports/api/methods/createLink.tests.js
  17. 1
      imports/api/methods/index.js
  18. 1
      imports/api/publications/index.js
  19. 6
      imports/api/publications/links.js
  20. 22
      imports/api/publications/links.tests.js
  21. 26
      imports/ui/App.vue
  22. 27
      imports/ui/components/Hello.vue
  23. 55
      imports/ui/components/Info.vue
  24. 4
      imports/ui/plugins.js
  25. 24
      package.json
  26. 3
      server/main.js
  27. 20
      tests/main.js

50
.docker/Dockerfile

@ -0,0 +1,50 @@
FROM node:12.18.4-buster-slim
LABEL maintainer="buildmaster@rocket.chat"
# dependencies
RUN groupadd -g 65533 -r rocketchat \
&& useradd -u 65533 -r -g rocketchat rocketchat \
&& mkdir -p /app/uploads \
&& chown rocketchat:rocketchat /app/uploads \
&& apt-get update \
&& apt-get install -y --no-install-recommends fontconfig
#ADD .. /app
ADD ../bundle /app/bundle
RUN aptMark="$(apt-mark showmanual)" \
&& apt-get install -y --no-install-recommends g++ make python ca-certificates \
&& cd /app/bundle/programs/server \
&& npm install \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $aptMark > /dev/null \
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app
USER rocketchat
VOLUME /app/uploads
WORKDIR /app/bundle
# needs a mongoinstance - defaults to container linking with alias 'mongo'
ENV DEPLOY_METHOD=docker \
NODE_ENV=production \
MONGO_URL=mongodb://mongo:27017/rocketchat \
HOME=/tmp \
PORT=3000 \
ROOT_URL=http://localhost:3000 \
Accounts_AvatarStorePath=/app/uploads
EXPOSE 3000
CMD ["node", "main.js"]

2
.gitignore

@ -0,0 +1,2 @@
node_modules/
/package-lock.json

19
.meteor/.finished-upgraders

@ -0,0 +1,19 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.
notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
1.4.3-split-account-service-packages
1.5-add-dynamic-import-package
1.7-split-underscore-from-meteor-base
1.8.3-split-jquery-from-blaze

1
.meteor/.gitignore

@ -0,0 +1 @@
local

7
.meteor/.id

@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics
vj567esl31n.obedb45x5fst

24
.meteor/packages

@ -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@1.4.0 # Packages every Meteor app needs to have
mobile-experience@1.1.0 # Packages for a great mobile UX
mongo@1.10.0 # The database Meteor supports right now
reactive-var@1.0.11 # Reactive variable for tracker
standard-minifier-css@1.6.1 # CSS minifier run for production mode
standard-minifier-js@2.6.0 # JS minifier run for production mode
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.14.3 # Enable ECMAScript2015+ syntax in app code
typescript@3.7.6 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.5.0 # Server-side component of the `meteor shell` command
tracker@1.2.0 # 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

2
.meteor/platforms

@ -0,0 +1,2 @@
server
browser

1
.meteor/release

@ -0,0 +1 @@
METEOR@1.11.1

78
.meteor/versions

@ -0,0 +1,78 @@
akryum:vue-component@0.15.2
akryum:vue-component-dev-client@0.4.7
akryum:vue-component-dev-server@0.1.4
allow-deny@1.1.0
autoupdate@1.6.0
babel-compiler@7.5.3
babel-runtime@1.5.0
base64@1.0.12
binary-heap@1.0.11
blaze-tools@1.0.10
boilerplate-generator@1.7.1
caching-compiler@1.2.2
caching-html-compiler@1.1.3
callback-hook@1.3.0
check@1.3.1
ddp@1.4.0
ddp-client@2.3.3
ddp-common@1.4.0
ddp-server@2.3.2
deps@1.0.12
diff-sequence@1.1.1
dynamic-import@0.5.2
ecmascript@0.14.3
ecmascript-runtime@0.7.0
ecmascript-runtime-client@0.11.0
ecmascript-runtime-server@0.10.0
ejson@1.1.1
es5-shim@4.8.0
fetch@0.1.1
geojson-utils@1.0.10
hot-code-push@1.0.4
html-tools@1.0.11
htmljs@1.0.11
http@1.4.2
id-map@1.1.0
inter-process-messaging@0.1.1
johanbrook:publication-collector@1.1.0
launch-screen@1.2.0
livedata@1.0.18
logging@1.1.20
meteor@1.9.3
meteor-base@1.4.0
meteortesting:browser-tests@1.3.4
meteortesting:mocha@2.0.1
meteortesting:mocha-core@8.0.1
minifier-css@1.5.3
minifier-js@2.6.0
minimongo@1.6.0
mobile-experience@1.1.0
mobile-status-bar@1.1.0
modern-browsers@0.1.5
modules@0.15.0
modules-runtime@0.12.0
mongo@1.10.0
mongo-decimal@0.1.1
mongo-dev-server@1.1.0
mongo-id@1.0.7
npm-mongo@3.8.1
ordered-dict@1.1.0
promise@0.11.2
random@1.2.0
reactive-var@1.0.11
reload@1.3.0
retry@1.1.0
routepolicy@1.1.0
shell-server@0.5.0
socket-stream-client@0.3.1
spacebars-compiler@1.1.3
standard-minifier-css@1.6.1
standard-minifier-js@2.6.0
static-html@1.2.2
templating-tools@1.1.2
tracker@1.2.0
typescript@3.7.6
underscore@1.0.10
url@1.3.1
webapp@1.9.1
webapp-hashing@1.0.9

7
client/main.html

@ -0,0 +1,7 @@
<head>
<title>vue-test</title>
</head>
<body>
<div id="app"></div>
</body>

12
client/main.js

@ -0,0 +1,12 @@
import Vue from 'vue'
import '../imports/ui/plugins'
import App from '../imports/ui/App.vue'
Meteor.startup(() => {
new Vue({
el: '#app',
...App,
})
})

3
imports/api/collections/Links.js

@ -0,0 +1,3 @@
import { Mongo } from 'meteor/mongo';
export default new Mongo.Collection('links');

24
imports/api/collections/Links.tests.js

@ -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);
});
});
}

32
imports/api/fixtures.js

@ -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));
}
});

16
imports/api/methods/createLink.js

@ -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
imports/api/methods/createLink.tests.js

@ -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);
});
});
}

1
imports/api/methods/index.js

@ -0,0 +1 @@
import './createLink'

1
imports/api/publications/index.js

@ -0,0 +1 @@
import './links'

6
imports/api/publications/links.js

@ -0,0 +1,6 @@
import { Meteor } from 'meteor/meteor';
import Links from '../collections/Links.js';
Meteor.publish('links', function () {
return Links.find();
});

22
imports/api/publications/links.tests.js

@ -0,0 +1,22 @@
import { assert } from 'chai'
import { PublicationCollector } from 'meteor/johanbrook:publication-collector'
import Links from '../collections/Links.js'
import './publications.js'
describe('Publish links', function () {
beforeEach(function () {
Links.remove({})
Links.insert({
title: 'meteor homepage',
url: 'https://www.meteor.com'
})
})
it('sends all links', function (done) {
const collector = new PublicationCollector()
collector.collect('links', (collections) => {
assert.equal(collections.links.length, 1)
done()
})
})
})

26
imports/ui/App.vue

@ -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>

27
imports/ui/components/Hello.vue

@ -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>

55
imports/ui/components/Info.vue

@ -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 '../../api/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>

4
imports/ui/plugins.js

@ -0,0 +1,4 @@
import Vue from 'vue'
import VueMeteorTracker from 'vue-meteor-tracker'
Vue.use(VueMeteorTracker)

24
package.json

@ -0,0 +1,24 @@
{
"name": "vue-test",
"private": true,
"scripts": {
"start": "meteor run",
"build": "meteor build --directory ./",
"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.11.2",
"meteor-node-stubs": "^1.0.1",
"vue": "^2.6.12",
"vue-meteor-tracker": "^2.0.0-beta.5"
},
"meteor": {
"mainModule": {
"client": "client/main.js",
"server": "server/main.js"
},
"testModule": "tests/main.js"
}
}

3
server/main.js

@ -0,0 +1,3 @@
import '../imports/api/fixtures'
import '../imports/api/methods'
import '../imports/api/publications'

20
tests/main.js

@ -0,0 +1,20 @@
import assert from "assert";
describe("skel", function () {
it("package.json has correct name", async function () {
const { name } = await import("../package.json");
assert.strictEqual(name, "skel");
});
if (Meteor.isClient) {
it("client is not server", function () {
assert.strictEqual(Meteor.isServer, false);
});
}
if (Meteor.isServer) {
it("server is not client", function () {
assert.strictEqual(Meteor.isClient, false);
});
}
});
Завантаження…
Відмінити
Зберегти