Skip to content

Commit 436e8a7

Browse files
author
Maksym Mykhailenko
committed
Merge branch 'develop' into feature/bulk-milestone-updates
# Conflicts: # src/routes/milestones/update.js
2 parents e26a053 + 5b4f53b commit 436e8a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3866
-1476
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.16.1
1+
12

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:8.2.1
1+
FROM node:12.16.1
22
LABEL version="1.2"
33
LABEL description="Projects microservice"
44
RUN sed -i '/jessie-updates/d' /etc/apt/sources.list

README.md

Lines changed: 148 additions & 110 deletions
Large diffs are not rendered by default.

config/default.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"url": "localhost:9092"
4040
},
4141
"analyticsKey": "",
42-
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
43-
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
42+
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\",\"https:\/\/topcoder-dev.auth0.com\/\"]",
43+
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\",\"https:\/\/topcoder-dev.auth0.com\/\"]",
4444
"jwksUri": "",
4545
"busApiUrl": "http://api.topcoder-dev.com/v5",
4646
"messageApiUrl": "http://api.topcoder-dev.com/v5",

data/demo-data.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

docs/permissions.html

Lines changed: 1299 additions & 0 deletions
Large diffs are not rendered by default.

local/seed/seedMetadata.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ if (!process.env.CONNECT_USER_TOKEN) {
77
process.exit(1);
88
}
99

10+
/**
11+
* Iteratively goes through the object and replaces prices with random values.
12+
*
13+
* This method MUTATES object.
14+
*
15+
* @param {Object} o object
16+
*/
17+
function dummifyPrices(o) {
18+
Object.keys(o).forEach(function (k) {
19+
if (o[k] !== null && typeof o[k] === 'object') {
20+
dummifyPrices(o[k]);
21+
return;
22+
}
23+
if (k === 'price' && typeof o[k] === 'number') {
24+
o[k] = 100 + Math.round(Math.random() * 10000);
25+
}
26+
if (k === 'price' && typeof o[k] === 'string') {
27+
o[k] = (100 + Math.round(Math.random() * 10000)).toFixed(0);
28+
}
29+
});
30+
}
31+
1032
// we need to know any logged in Connect user token to retrieve data from DEV
1133
const CONNECT_USER_TOKEN = process.env.CONNECT_USER_TOKEN;
1234

@@ -29,6 +51,7 @@ module.exports = (targetUrl, token) => {
2951
})
3052
.then(async function (response) {
3153
let data = response.data;
54+
dummifyPrices(data)
3255

3356
console.log('Creating metadata objects locally...');
3457

package-lock.json

Lines changed: 66 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"lint": "./node_modules/.bin/eslint .",
1111
"lint:fix": "./node_modules/.bin/eslint . --fix || true",
1212
"build": "babel src -d dist --presets es2015 --copy-files",
13+
"sync:all": "NODE_ENV=development npm run sync:db && NODE_ENV=development npm run sync:es",
1314
"sync:db": "./node_modules/.bin/babel-node migrations/sync.js",
1415
"sync:es": "./node_modules/.bin/babel-node migrations/elasticsearch_sync.js",
1516
"sync:es:metadata": "./node_modules/.bin/babel-node migrations/elasticsearch_sync.js --index-name metadata",
@@ -19,14 +20,19 @@
1920
"migrate:bookmarks:revert": "./node_modules/.bin/babel-node migrations/bookmarks/migrateLinksToBookmarks.js",
2021
"prestart": "npm run -s build",
2122
"start": "node dist",
22-
"start:dev": "NODE_ENV=development PORT=8001 nodemon -w src --exec \"babel-node src --presets es2015\" | ./node_modules/.bin/bunyan",
23+
"start:dev": "NODE_ENV=development PORT=8001 nodemon -w src --exec \"node --require dotenv/config --require babel-core/register src\" | ./node_modules/.bin/bunyan",
2324
"startKafkaConsumers": "npm run -s build && node dist/index-kafka.js",
2425
"startKafkaConsumers:dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src/index-kafka.js --presets es2015\" | ./node_modules/.bin/bunyan",
2526
"test": "NODE_ENV=test npm run lint && NODE_ENV=test npm run sync:es && NODE_ENV=test npm run sync:db && NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- --timeout 10000 --require babel-core/register $(find src -path '*spec.js*') --exit",
2627
"test:watch": "NODE_ENV=test ./node_modules/.bin/mocha -w --require babel-core/register $(find src -path '*spec.js*')",
27-
"seed": "babel-node src/tests/seed.js --presets es2015",
2828
"demo-data": "babel-node local/seed",
29-
"es-db-compare": "babel-node scripts/es-db-compare"
29+
"es-db-compare": "babel-node scripts/es-db-compare",
30+
"data:export": "NODE_ENV=development LOG_LEVEL=info node --require dotenv/config --require babel-core/register scripts/data/export",
31+
"data:import": "NODE_ENV=development LOG_LEVEL=info node --require dotenv/config --require babel-core/register scripts/data/import",
32+
"local:run-docker": "docker-compose -f ./local/full/docker-compose.yml up -d",
33+
"local:init": "npm run sync:all && npm run data:import",
34+
"generate:doc:permissions": "babel-node scripts/permissions-doc",
35+
"generate:doc:permissions:dev": "nodemon --watch scripts/permissions-doc --watch src --ext js,jsx,hbs --exec babel-node scripts/permissions-doc"
3036
},
3137
"repository": {
3238
"type": "git",
@@ -51,6 +57,7 @@
5157
"config": "^1.20.1",
5258
"continuation-local-storage": "^3.1.7",
5359
"cors": "^2.8.4",
60+
"dotenv": "^8.2.0",
5461
"elasticsearch": "^16.1.1",
5562
"express": "^4.13.4",
5663
"express-list-routes": "^0.1.4",
@@ -71,7 +78,7 @@
7178
"pg-native": "^3.0.0",
7279
"sequelize": "^5.8.7",
7380
"swagger-ui-express": "^4.0.6",
74-
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6.3",
81+
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
7582
"traverse": "^0.6.6",
7683
"urlencode": "^1.1.0",
7784
"yamljs": "^0.3.0"

scripts/data/dataModels.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// So that importing operation succeeds, models are added to list such that each model comes after its dependencies,
2+
// So, when you add a new model to the list, make sure that its dependencies exist and come before it.
3+
import models from '../../src/models';
4+
5+
const dataModels = [
6+
'ProjectTemplate',
7+
'ProductTemplate',
8+
'ProjectType',
9+
'ProductCategory',
10+
'MilestoneTemplate',
11+
'OrgConfig',
12+
'Form',
13+
'PlanConfig',
14+
'PriceConfig',
15+
'BuildingBlock',
16+
'Project',
17+
'ProjectPhase',
18+
'PhaseProduct',
19+
'ProjectAttachment',
20+
'ProjectMember',
21+
'ProjectMemberInvite',
22+
];
23+
/**
24+
* Validate that data models to be imported/exported are defined in model scope
25+
* @return {void} Returns void
26+
*/
27+
function validateDataModels() {
28+
// Validate model names
29+
dataModels.forEach((modelName) => {
30+
if (!models[modelName]) {
31+
throw new Error(`Invalid model: ${modelName}`);
32+
}
33+
});
34+
}
35+
module.exports = { dataModels, validateDataModels };

0 commit comments

Comments
 (0)