mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 12:23:05 +00:00
Fix config policies aggregation & improve post-install script
This commit is contained in:
parent
9c0444e085
commit
1304a5cde0
@ -1,4 +1,4 @@
|
||||
import { get, includes, isArray, set } from 'lodash';
|
||||
import { get, includes, isArray, set, omit } from 'lodash';
|
||||
import { call, fork, takeLatest, put, select } from 'redux-saga/effects';
|
||||
import auth from 'utils/auth';
|
||||
import request from 'utils/request';
|
||||
@ -40,6 +40,17 @@ export function* submitForm(action) {
|
||||
|
||||
if (formType === 'register') {
|
||||
action.context.updatePlugin('users-permissions', 'hasAdminUser', true);
|
||||
|
||||
try {
|
||||
yield call(request, 'http://localhost:1338/register', {
|
||||
method: 'POST',
|
||||
mode: 'no-cors',
|
||||
body: omit(body, ['password', 'confirmPassword']),
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
// Silent.
|
||||
}
|
||||
}
|
||||
|
||||
yield put(submitSucceeded());
|
||||
|
@ -121,6 +121,7 @@ class Strapi extends EventEmitter {
|
||||
} catch (e) {
|
||||
this.log.debug(`Server wasn't able to start properly.`);
|
||||
this.log.error(e);
|
||||
console.error(e);
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
@ -78,18 +78,27 @@ module.exports = {
|
||||
},
|
||||
|
||||
loadConfig: function(files) {
|
||||
const aggregate = files.filter(
|
||||
p =>
|
||||
intersection(p.split('/').map(p => p.replace('.json', '')), ['environments', 'database', 'security', 'request', 'response', 'server']).length === 2 ||
|
||||
((p.indexOf('functions') !== -1 ||
|
||||
p.indexOf('policies') !== -1 ||
|
||||
p.indexOf('locales') !== -1 ||
|
||||
p.indexOf('hook') !== -1 ||
|
||||
p.indexOf('middleware') !== -1 ||
|
||||
p.indexOf('language') !== -1 ||
|
||||
p.indexOf('queries') !== -1 ||
|
||||
p.indexOf('layout') !== -1) && p.indexOf('api') === -1)
|
||||
);
|
||||
const aggregate = files.filter(p => {
|
||||
if (intersection(p.split('/').map(p => p.replace('.json', '')), ['environments', 'database', 'security', 'request', 'response', 'server']).length === 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
p.indexOf('config/functions') !== -1 ||
|
||||
p.indexOf('config/policies') !== -1 ||
|
||||
p.indexOf('config/locales') !== -1 ||
|
||||
p.indexOf('config/hook') !== -1 ||
|
||||
p.indexOf('config/middleware') !== -1 ||
|
||||
p.indexOf('config/language') !== -1 ||
|
||||
p.indexOf('config/queries') !== -1 ||
|
||||
p.indexOf('config/layout') !== -1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
const optional = difference(files, aggregate);
|
||||
|
||||
return Promise.all([
|
||||
|
@ -15,13 +15,15 @@ const _ = require('lodash');
|
||||
// Define files/dir paths
|
||||
const pluginsDirPath = path.join(process.cwd(), 'plugins');
|
||||
const adminDirPath = path.join(process.cwd(), 'admin');
|
||||
const plugins = fs.readdirSync(pluginsDirPath).filter(x => x[0] !== '.');
|
||||
|
||||
// Install admin dependencies
|
||||
console.log(`🔸 Administration Panel`);
|
||||
console.log('📦 Installing packages...');
|
||||
|
||||
try {
|
||||
// Check if path is existing.
|
||||
fs.accessSync(adminDirPath, fs.constants.R_OK | fs.constants.W_OK);
|
||||
|
||||
const install = exec(`cd ${adminDirPath} && npm install --prod --ignore-scripts`, {
|
||||
silent: true
|
||||
});
|
||||
@ -34,29 +36,52 @@ try {
|
||||
console.log('✅ Success');
|
||||
console.log('');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
// Install dependencies for each plugins
|
||||
_.forEach(plugins, plugin => {
|
||||
const pluginPath = path.join(pluginsDirPath, plugin);
|
||||
|
||||
console.log(`🔸 Plugin - ${_.upperFirst(plugin)}`);
|
||||
console.log('📦 Installing packages...');
|
||||
|
||||
try {
|
||||
const install = exec(`cd ${pluginPath} && npm install --prod --ignore-scripts`, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
if (install.stderr && install.code !== 0) {
|
||||
console.error(install.stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (err.code === 'ENOENT') {
|
||||
console.log('✅ Success');
|
||||
console.log('');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
try {
|
||||
// Check if path is existing.
|
||||
fs.accessSync(pluginsDirPath, fs.constants.R_OK | fs.constants.W_OK);
|
||||
|
||||
const plugins = fs.readdirSync(pluginsDirPath).filter(x => x[0] !== '.');
|
||||
|
||||
// Install dependencies for each plugins
|
||||
_.forEach(plugins, plugin => {
|
||||
const pluginPath = path.join(pluginsDirPath, plugin);
|
||||
|
||||
console.log(`🔸 Plugin - ${_.upperFirst(plugin)}`);
|
||||
console.log('📦 Installing packages...');
|
||||
|
||||
try {
|
||||
const install = exec(`cd ${pluginPath} && npm install --prod --ignore-scripts`, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
if (install.stderr && install.code !== 0) {
|
||||
console.error(install.stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('✅ Success');
|
||||
console.log('');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
if (err.code === 'ENOENT') {
|
||||
console.log('✅ Success');
|
||||
console.log('');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user