From 6fe91b36d57d2fd1545c9c50829d9aa32c4e3c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E9=B9=8F?= Date: Tue, 20 Oct 2020 10:49:56 +0800 Subject: [PATCH] init --- .docker/Dockerfile | 50 ++++++++++++++++ .gitignore | 2 + .meteor/.finished-upgraders | 19 ++++++ .meteor/.gitignore | 1 + .meteor/.id | 7 +++ .meteor/packages | 24 ++++++++ .meteor/platforms | 2 + .meteor/release | 1 + .meteor/versions | 78 +++++++++++++++++++++++++ client/main.html | 7 +++ client/main.js | 12 ++++ imports/api/collections/Links.js | 3 + imports/api/collections/Links.tests.js | 24 ++++++++ imports/api/fixtures.js | 32 ++++++++++ imports/api/methods/createLink.js | 16 +++++ imports/api/methods/createLink.tests.js | 20 +++++++ imports/api/methods/index.js | 1 + imports/api/publications/index.js | 1 + imports/api/publications/links.js | 6 ++ imports/api/publications/links.tests.js | 22 +++++++ imports/ui/App.vue | 26 +++++++++ imports/ui/components/Hello.vue | 27 +++++++++ imports/ui/components/Info.vue | 55 +++++++++++++++++ imports/ui/plugins.js | 4 ++ package.json | 24 ++++++++ server/main.js | 3 + tests/main.js | 20 +++++++ 27 files changed, 487 insertions(+) create mode 100644 .docker/Dockerfile create mode 100644 .gitignore create mode 100644 .meteor/.finished-upgraders create mode 100644 .meteor/.gitignore create mode 100644 .meteor/.id create mode 100644 .meteor/packages create mode 100644 .meteor/platforms create mode 100644 .meteor/release create mode 100644 .meteor/versions create mode 100644 client/main.html create mode 100644 client/main.js create mode 100644 imports/api/collections/Links.js create mode 100644 imports/api/collections/Links.tests.js create mode 100644 imports/api/fixtures.js create mode 100644 imports/api/methods/createLink.js create mode 100644 imports/api/methods/createLink.tests.js create mode 100644 imports/api/methods/index.js create mode 100644 imports/api/publications/index.js create mode 100644 imports/api/publications/links.js create mode 100644 imports/api/publications/links.tests.js create mode 100644 imports/ui/App.vue create mode 100644 imports/ui/components/Hello.vue create mode 100644 imports/ui/components/Info.vue create mode 100644 imports/ui/plugins.js create mode 100644 package.json create mode 100644 server/main.js create mode 100644 tests/main.js diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..43ee2f4 --- /dev/null +++ b/.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"] \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0475271 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +/package-lock.json diff --git a/.meteor/.finished-upgraders b/.meteor/.finished-upgraders new file mode 100644 index 0000000..c07b6ff --- /dev/null +++ b/.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 diff --git a/.meteor/.gitignore b/.meteor/.gitignore new file mode 100644 index 0000000..4083037 --- /dev/null +++ b/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/.meteor/.id b/.meteor/.id new file mode 100644 index 0000000..ad2badb --- /dev/null +++ b/.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 diff --git a/.meteor/packages b/.meteor/packages new file mode 100644 index 0000000..cd6d70f --- /dev/null +++ b/.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 diff --git a/.meteor/platforms b/.meteor/platforms new file mode 100644 index 0000000..efeba1b --- /dev/null +++ b/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/.meteor/release b/.meteor/release new file mode 100644 index 0000000..019e3ae --- /dev/null +++ b/.meteor/release @@ -0,0 +1 @@ +METEOR@1.11.1 diff --git a/.meteor/versions b/.meteor/versions new file mode 100644 index 0000000..32c30a5 --- /dev/null +++ b/.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 diff --git a/client/main.html b/client/main.html new file mode 100644 index 0000000..cc9c0c8 --- /dev/null +++ b/client/main.html @@ -0,0 +1,7 @@ + + vue-test + + + +
+ diff --git a/client/main.js b/client/main.js new file mode 100644 index 0000000..244595f --- /dev/null +++ b/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, + }) +}) diff --git a/imports/api/collections/Links.js b/imports/api/collections/Links.js new file mode 100644 index 0000000..872bb75 --- /dev/null +++ b/imports/api/collections/Links.js @@ -0,0 +1,3 @@ +import { Mongo } from 'meteor/mongo'; + +export default new Mongo.Collection('links'); diff --git a/imports/api/collections/Links.tests.js b/imports/api/collections/Links.tests.js new file mode 100644 index 0000000..ce17851 --- /dev/null +++ b/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); + }); + }); +} diff --git a/imports/api/fixtures.js b/imports/api/fixtures.js new file mode 100644 index 0000000..f629f5c --- /dev/null +++ b/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)); + } +}); diff --git a/imports/api/methods/createLink.js b/imports/api/methods/createLink.js new file mode 100644 index 0000000..876f710 --- /dev/null +++ b/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(), + }); + }, +}); diff --git a/imports/api/methods/createLink.tests.js b/imports/api/methods/createLink.tests.js new file mode 100644 index 0000000..d899a73 --- /dev/null +++ b/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); + }); + }); +} diff --git a/imports/api/methods/index.js b/imports/api/methods/index.js new file mode 100644 index 0000000..ce2687f --- /dev/null +++ b/imports/api/methods/index.js @@ -0,0 +1 @@ +import './createLink' diff --git a/imports/api/publications/index.js b/imports/api/publications/index.js new file mode 100644 index 0000000..45acd59 --- /dev/null +++ b/imports/api/publications/index.js @@ -0,0 +1 @@ +import './links' diff --git a/imports/api/publications/links.js b/imports/api/publications/links.js new file mode 100644 index 0000000..f085d75 --- /dev/null +++ b/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(); +}); diff --git a/imports/api/publications/links.tests.js b/imports/api/publications/links.tests.js new file mode 100644 index 0000000..37f337c --- /dev/null +++ b/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() + }) + }) +}) diff --git a/imports/ui/App.vue b/imports/ui/App.vue new file mode 100644 index 0000000..e126098 --- /dev/null +++ b/imports/ui/App.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/imports/ui/components/Hello.vue b/imports/ui/components/Hello.vue new file mode 100644 index 0000000..64947eb --- /dev/null +++ b/imports/ui/components/Hello.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/imports/ui/components/Info.vue b/imports/ui/components/Info.vue new file mode 100644 index 0000000..376d605 --- /dev/null +++ b/imports/ui/components/Info.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/imports/ui/plugins.js b/imports/ui/plugins.js new file mode 100644 index 0000000..9d8e6b9 --- /dev/null +++ b/imports/ui/plugins.js @@ -0,0 +1,4 @@ +import Vue from 'vue' +import VueMeteorTracker from 'vue-meteor-tracker' + +Vue.use(VueMeteorTracker) diff --git a/package.json b/package.json new file mode 100644 index 0000000..c2c2342 --- /dev/null +++ b/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" + } +} diff --git a/server/main.js b/server/main.js new file mode 100644 index 0000000..db94e8b --- /dev/null +++ b/server/main.js @@ -0,0 +1,3 @@ +import '../imports/api/fixtures' +import '../imports/api/methods' +import '../imports/api/publications' diff --git a/tests/main.js b/tests/main.js new file mode 100644 index 0000000..6d2a32e --- /dev/null +++ b/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); + }); + } +});