diff --git a/package.json b/package.json index 5a3f7380c..223568bb6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "test": "node --expose-gc --max_old_space_size=4000 ./node_modules/.bin/jest --runInBand --forceExit --silent --logHeapUsage && ts-node ./src/commands/aftertest.ts", "generateVersion": "ts-node ./src/commands/generateVersion.ts", "loadInitialData": "ts-node ./src/commands/loadInitialData.ts", - "loadPermission": "mongorestore --db erxes ./src/permissionData", + "loadPermission": "ts-node ./src/commands/loadPermissionData.ts", "initProject": "ts-node ./src/commands/initProject.ts", "createGooglePubsubTopics": "ts-node ./src/commands/createGooglePubsubTopics.ts", "customCommand": "ts-node ./src/commands/customCommand.ts", diff --git a/src/commands/loadInitialData.ts b/src/commands/loadInitialData.ts index c982a5a39..2e710e8e2 100644 --- a/src/commands/loadInitialData.ts +++ b/src/commands/loadInitialData.ts @@ -5,7 +5,7 @@ import { Users } from '../db/models'; const main = async () => { const MONGO_URL = getEnv({ name: 'MONGO_URL' }); - const result = await shelljs.exec(`mongorestore --db erxes ./src/initialData`, { silent: true }); + const result = await shelljs.exec(`mongorestore --uri ${MONGO_URL} --db erxes ./src/initialData`, { silent: true }); const output = result.stderr + result.stdout; console.log(output); diff --git a/src/commands/loadPermissionData.ts b/src/commands/loadPermissionData.ts new file mode 100644 index 000000000..ce9488c0a --- /dev/null +++ b/src/commands/loadPermissionData.ts @@ -0,0 +1,17 @@ +import * as shelljs from 'shelljs'; +import { getEnv } from '../data/utils'; + +const main = async () => { + const MONGO_URL = getEnv({ name: 'MONGO_URL' }); + + const result = await shelljs.exec(`mongorestore --uri ${MONGO_URL} --db erxes ./src/permissionData`, { + silent: true, + }); + const output = result.stderr + result.stdout; + + console.log(output); + + process.exit(); +}; + +main();