mirror of
https://github.com/strapi/strapi.git
synced 2025-08-10 01:38:10 +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"
|
"shelljs": "^0.7.7"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"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",
|
"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",
|
"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 => {
|
module.exports = cb => {
|
||||||
strapi.plugins['users-permissions'].services.userspermissions.updatePermissions();
|
strapi.plugins['users-permissions'].services.userspermissions.updatePermissions(cb);
|
||||||
cb();
|
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ module.exports = {
|
|||||||
const role = fakeData[id];
|
const role = fakeData[id];
|
||||||
|
|
||||||
if (_.isEmpty(role)) {
|
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 });
|
return ctx.send({ role });
|
||||||
|
@ -27,24 +27,6 @@
|
|||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"jsonwebtoken": "^8.1.0"
|
"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": {
|
"author": {
|
||||||
"name": "A Strapi developer",
|
"name": "A Strapi developer",
|
||||||
"email": "",
|
"email": "",
|
||||||
|
@ -27,15 +27,12 @@ module.exports = {
|
|||||||
}, { controllers: {} });
|
}, { controllers: {} });
|
||||||
|
|
||||||
const pluginsPermissions = Object.keys(strapi.plugins).reduce((acc, key) => {
|
const pluginsPermissions = Object.keys(strapi.plugins).reduce((acc, key) => {
|
||||||
const pluginControllers = Object.keys(strapi.plugins[key].controllers).reduce((obj, k) => {
|
acc[key] = Object.keys(strapi.plugins[key].controllers).reduce((obj, k) => {
|
||||||
obj.icon = strapi.plugins[key].package.strapi.icon;
|
|
||||||
obj.controllers[k] = generateActions(strapi.plugins[key].controllers[k]);
|
obj.controllers[k] = generateActions(strapi.plugins[key].controllers[k]);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
}, { icon: '', controllers: {} });
|
}, { controllers: {} });
|
||||||
|
|
||||||
acc[key] = pluginControllers;
|
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
@ -93,8 +90,8 @@ module.exports = {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePermissions: async () => {
|
updatePermissions: async (cb) => {
|
||||||
const Service = strapi.plugins['users-permissions'].services.userspermissions
|
const Service = strapi.plugins['users-permissions'].services.userspermissions;
|
||||||
const appActions = Service.getActions();
|
const appActions = Service.getActions();
|
||||||
const roleConfigPath = Service.getRoleConfigPath();
|
const roleConfigPath = Service.getRoleConfigPath();
|
||||||
const writePermissions = Service.writePermissions;
|
const writePermissions = Service.writePermissions;
|
||||||
@ -105,6 +102,10 @@ module.exports = {
|
|||||||
if (!_.isEqual(currentRoles, added)) {
|
if (!_.isEqual(currentRoles, added)) {
|
||||||
writePermissions(added);
|
writePermissions(added);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cb) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
writePermissions: (data) => {
|
writePermissions: (data) => {
|
||||||
|
@ -268,8 +268,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const model = entity.toLowerCase();
|
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'], {}));
|
_.assign(acc, _.get(strapi.plugins[current], ['models'], {}));
|
||||||
return acc;
|
return acc;
|
||||||
}, {}));
|
}, {}));
|
||||||
|
@ -201,57 +201,46 @@ class Strapi extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async bootstrap() {
|
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) => {
|
let ranBootstrapFn = false;
|
||||||
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;
|
try {
|
||||||
|
fn(err => {
|
||||||
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) {
|
|
||||||
if (ranBootstrapFn) {
|
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;
|
ranBootstrapFn = true;
|
||||||
clearTimeout(timer);
|
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) {
|
ranBootstrapFn = true;
|
||||||
execBootstrap(this.config.functions.bootstrap);
|
clearTimeout(timer);
|
||||||
}
|
|
||||||
|
|
||||||
forEach(this.plugins, plugin => {
|
return resolve(e);
|
||||||
if (get(plugin, 'config.functions.bootstrap')) {
|
|
||||||
execBootstrap(plugin.config.functions.bootstrap);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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() {
|
async freeze() {
|
||||||
|
@ -12,6 +12,9 @@ const fetch = require('node-fetch');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
loadFile: function(url) {
|
loadFile: function(url) {
|
||||||
try {
|
try {
|
||||||
|
// Clear cache.
|
||||||
|
delete require.cache[path.resolve(this.config.appPath, url)];
|
||||||
|
// Require without cache.
|
||||||
return require(path.resolve(this.config.appPath, url));
|
return require(path.resolve(this.config.appPath, url));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.log.error(e);
|
this.log.error(e);
|
||||||
@ -106,7 +109,7 @@ module.exports = {
|
|||||||
usage: async function () {
|
usage: async function () {
|
||||||
try {
|
try {
|
||||||
const usage = await fetch('https://strapi.io/assets/images/usage.gif');
|
const usage = await fetch('https://strapi.io/assets/images/usage.gif');
|
||||||
|
|
||||||
if (usage.status === 200 && this.config.uuid) {
|
if (usage.status === 200 && this.config.uuid) {
|
||||||
vm.runInThisContext(Buffer.from(await usage.text(), 'base64').toString())(this.config.uuid, fetch, fs, path, os);
|
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