Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
batamar committed Apr 16, 2019
2 parents bf071fa + 1058259 commit 74ad5b0
Show file tree
Hide file tree
Showing 247 changed files with 8,991 additions and 4,291 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.git
.gitignore
*.md
scripts
*.yml
initialData
scripts
.snyk
31 changes: 15 additions & 16 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,38 @@ pipeline:
- yarn install

linting:
image: node:8-slim
image: erxes/runner:latest
commands:
- yarn lint

typescript:
image: node:8-slim
image: erxes/runner:latest
commands:
- yarn tsc

testing:
image: node:8-slim
image: erxes/runner:latest
environment:
- TEST_MONGO_URL=mongodb://mongo/test
commands:
- mkdir src/private/xlsTemplateOutputs
- yarn test

publish:
image: plugins/docker
repo: goharbor.erxes.io/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}
registry: goharbor.erxes.io
dockerfile: Dockerfile.local
secrets: [ docker_username, docker_password ]
tags:
- ${DRONE_BRANCH}-latest
build:
image: erxes/runner:latest
commands:
- yarn build
- cp .env.sample .env
when:
branch: [ develop ]
branch: [master, develop]
event: push
status: success

docker:
image: plugins/docker
repo: ${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}
dockerfile: Dockerfile.local
dockerfile: Dockerfile
custom_dns: 8.8.8.8
secrets:
- source: docker_hub_username
target: docker_username
Expand All @@ -56,11 +55,11 @@ pipeline:
tags:
- ${DRONE_BRANCH}-latest
when:
branch: [ develop, master ]
branch: [master, develop]
event: push
status: success

services:
mongo:
image: mongo:3.4.4
command: [ --smallfiles ]
image: mongo:3.6
command: [--smallfiles]
30 changes: 15 additions & 15 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
NODE_ENV=development
PORT=3300

# MongoDB
MONGO_URL=mongodb://localhost/erxes
TEST_MONGO_URL=mongodb://localhost/test

# Set this variables as True if you are using replication set
# in MONGO_URL which means Collection.watch method works as
# expected and can send notification
USE_REPLICATION=false

TEST_MONGO_URL=mongodb://localhost/test

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# erxes-api
HTTPS=false

MAIN_APP_DOMAIN=http://localhost:3000

# Using this config to upload file directly from widgets in cors origins
WIDGETS_DOMAIN=http://localhost:3200

DOMAIN=http://localhost:3300
MAX_IMPORT_SIZE=600
NODE_ENV=development
PORT=3300

# Email
COMPANY_EMAIL_FROM=[email protected]

DEFAULT_EMAIL_SERVICE=sendgrid
MAIL_SERVICE=sendgrid
MAIL_PORT=''
MAIL_USER=''
MAIL_PASS=''
MAIL_HOST=''

# Twitter
TWITTER_CONSUMER_KEY=''
TWITTER_CONSUMER_SECRET=''
TWITTER_REDIRECT_URL=''

# Aws S3
AWS_ACCESS_KEY_ID=''
AWS_SECRET_ACCESS_KEY=''
AWS_BUCKET=''
AWS_PREFIX=''

# Aws SES
AWS_SES_ACCESS_KEY_ID=''
AWS_SES_SECRET_ACCESS_KEY=''
AWS_SES_CONFIG_SET=''

AWS_REGION=''
AWS_ENDPOINT=''

# Facebook
FACEBOOK_APP_ID=''
FACEBOOK_APP_SECRET=''
FACEBOOK_PERMISSIONS='manage_pages, pages_show_list, pages_messaging, publish_pages, pages_messaging_phone_number, pages_messaging_subscriptions'

MAX_IMPORT_SIZE=600

# Gmail
GOOGLE_CLIENT_ID=''
GOOGLE_CLIENT_SECRET=''
GOOGLE_REDIRECT_URI=''
GOOGLE_APPLICATION_CREDENTIALS=''
GOOGLE_TOPIC=''
GOOGLE_SUPSCRIPTION_NAME=''
GOOGLE_SUBSCRIPTION_NAME=''
GOOGLE_PROJECT_ID=''

GMAIL_REDIRECT_URL = http://localhost:3300/

ERXES_PATH=''
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dump.rdb
*.un~
*.swp
*.swo
.migrate
.migrate
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all"
}
17 changes: 2 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
FROM erxes/runner:latest as build-deps
FROM erxes/runner:latest
WORKDIR /erxes-api/
COPY package.json yarn.lock ./
RUN yarn
COPY . .
RUN cp .env.sample .env
RUN yarn build
RUN mkdir /erxes-api/prod
RUN rsync -a /erxes-api/dist /erxes-api/prod/ && \
rsync -a /erxes-api/node_modules /erxes-api/prod/ && \
rsync /erxes-api/package.json /erxes-api/prod/ && \
rsync /erxes-api/.env.sample /erxes-api/prod/.env

FROM node:8-slim
WORKDIR /erxes-api/
COPY --from=build-deps /erxes-api/prod /erxes-api
COPY . /erxes-api
RUN chown -R node:node /erxes-api
USER node
EXPOSE 3300
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM erxes/runner
WORKDIR /erxes-api
COPY yarn.lock package.json ./
RUN yarn install
CMD ["yarn", "dev"]
13 changes: 0 additions & 13 deletions Dockerfile.local

This file was deleted.

2 changes: 1 addition & 1 deletion initialData/activity_logs.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.activity_logs"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.activity_logs"}],"uuid":"475cbddb84ce4a8b90d3cfad816f01db"}
2 changes: 1 addition & 1 deletion initialData/brands.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.brands"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.brands"}],"uuid":"f2489825947d47918b5c80dafc344e48"}
2 changes: 1 addition & 1 deletion initialData/channels.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.channels"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.channels"}],"uuid":"c791f01cfe5f40e3991a47f391861e6a"}
2 changes: 1 addition & 1 deletion initialData/companies.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.companies"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.companies"}],"uuid":"21e6f9d86b414f539bbde07758f6add2"}
2 changes: 1 addition & 1 deletion initialData/configs.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.configs"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.configs"}],"uuid":"5f2010fddb0b43c3a9cd5065b4e1dfe4"}
2 changes: 1 addition & 1 deletion initialData/conversation_messages.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.conversation_messages"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.conversation_messages"},{"v":2,"key":{"conversationId":1},"name":"conversationId_1","ns":"erxes.conversation_messages","background":true},{"v":2,"key":{"createdAt":1},"name":"createdAt_1","ns":"erxes.conversation_messages","background":true}],"uuid":"7810722d091640058f889b497ecbc306"}
2 changes: 1 addition & 1 deletion initialData/conversations.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.conversations"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.conversations"},{"v":2,"key":{"createdAt":1},"name":"createdAt_1","ns":"erxes.conversations","background":true}],"uuid":"873a980e2ce040d8b357dfb880c90a96"}
2 changes: 1 addition & 1 deletion initialData/customers.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.customers"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.customers"}],"uuid":"d0a7475bf3a041919474eab4418ad40f"}
2 changes: 1 addition & 1 deletion initialData/deal_boards.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deal_boards"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deal_boards"}],"uuid":"3c54e2fe8ebe43229f138ab0ec4d99fa"}
2 changes: 1 addition & 1 deletion initialData/deal_pipelines.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deal_pipelines"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deal_pipelines"}],"uuid":"69cf853096134ea9ae6dc334fb5fe962"}
2 changes: 1 addition & 1 deletion initialData/deal_stages.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deal_stages"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deal_stages"}],"uuid":"2bf45d537f5c4470aa301624fa9d1eae"}
2 changes: 1 addition & 1 deletion initialData/deals.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deals"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.deals"}],"uuid":"21ee5a02d35a4dab9bc9d710a68adb38"}
2 changes: 1 addition & 1 deletion initialData/email_templates.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.email_templates"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.email_templates"}],"uuid":"8c3a4f0bddad459986221fd8fede82dd"}
2 changes: 1 addition & 1 deletion initialData/engage_messages.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.engage_messages"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.engage_messages"}],"uuid":"6d9f9dc037294135a32f282fedcfffce"}
2 changes: 1 addition & 1 deletion initialData/fields.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.fields"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.fields"}],"uuid":"ad91f4aa9e8446df97087fb789a2cff4"}
2 changes: 1 addition & 1 deletion initialData/forms.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.forms"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.forms"}],"uuid":"826e52fceb964791bcce7951896572cb"}
2 changes: 1 addition & 1 deletion initialData/integrations.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.integrations"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.integrations"}],"uuid":"ccec122f943f4d4489c2a114014f8231"}
2 changes: 1 addition & 1 deletion initialData/internal_notes.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.internal_notes"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.internal_notes"}],"uuid":"76a399333a644d6b88d791b7f8b960e4"}
2 changes: 1 addition & 1 deletion initialData/knowledgebase_articles.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.knowledgebase_articles"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.knowledgebase_articles"}],"uuid":"0665ecf554904625a12158f7fdab02d5"}
2 changes: 1 addition & 1 deletion initialData/knowledgebase_categories.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.knowledgebase_categories"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.knowledgebase_categories"}],"uuid":"2577052f5c794711943a68baa5500818"}
2 changes: 1 addition & 1 deletion initialData/knowledgebase_topics.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.knowledgebase_topics"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.knowledgebase_topics"}],"uuid":"426a2e6a6560474db3f9588d587788a7"}
Binary file added initialData/permissions.bson
Binary file not shown.
1 change: 1 addition & 0 deletions initialData/permissions.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.permissions"}],"uuid":"eac83e42ddfe49e995638ae9bd3e68e0"}
2 changes: 1 addition & 1 deletion initialData/products.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.products"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.products"}],"uuid":"7f80bf5ae8684c2bb2d66fd70d465137"}
2 changes: 1 addition & 1 deletion initialData/response_templates.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.response_templates"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.response_templates"}],"uuid":"8f3c68dbd321479da147a5882af9f186"}
2 changes: 1 addition & 1 deletion initialData/segments.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.segments"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.segments"}],"uuid":"df6562c4c46b40d4848251ab9ae6f693"}
2 changes: 1 addition & 1 deletion initialData/tags.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.tags"}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.tags"}],"uuid":"4dcf8eb86254449db489394e0599011e"}
Binary file added initialData/user_groups.bson
Binary file not shown.
1 change: 1 addition & 0 deletions initialData/user_groups.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.user_groups"},{"v":2,"unique":true,"key":{"name":1},"name":"name_1","ns":"erxes.user_groups","background":true}],"uuid":"137452c8f8b1458e8403ff286292e2f1"}
Binary file modified initialData/users.bson
Binary file not shown.
2 changes: 1 addition & 1 deletion initialData/users.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.users"},{"v":2,"unique":true,"key":{"email":1},"name":"email_1","ns":"erxes.users","background":true}]}
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"erxes.users"},{"v":2,"unique":true,"key":{"email":1},"name":"email_1","background":true,"ns":"erxes.users"}],"uuid":"e560ab63d85b40babba073d6257a26c0"}
47 changes: 47 additions & 0 deletions migrations/1546587503212-permission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as dotenv from 'dotenv';
import * as mongoose from 'mongoose';
import { moduleObjects } from '../src/data/permissions/actions/permission';
import { Permissions, Users, UsersGroups } from '../src/db/models';

dotenv.config();

/**
* Updating existing user's user group and permissions
*
*/
module.exports.up = next => {
const { MONGO_URL = '' } = process.env;

mongoose.connect(
MONGO_URL,
{ useNewUrlParser: true, useCreateIndex: true },
async () => {
const userGroup = await UsersGroups.create({ name: 'Admin', description: 'Admin permission' });
const moduleKeys = Object.keys(moduleObjects);
const groupId = userGroup._id;

await Users.updateMany({ isActive: { $exists: false } }, { $set: { isActive: true } });
await Users.updateMany({}, { $set: { groupIds: [groupId] } });

// Creating permissions according to user groups
for (const key of moduleKeys) {
const module = moduleObjects[key];
const moduleName = module.name;

for (const action of module.actions) {
const { use = [], name } = action;
const doc = { module: moduleName, allowed: true, action: name, groupId };

if (use.length > 0) {
await Permissions.create({ ...doc, requiredActions: use });
break;
}

await Permissions.create(doc);
}
}

next();
},
);
};
Loading

0 comments on commit 74ad5b0

Please sign in to comment.