Allow plugins without admin && fix babel polyfill error

This commit is contained in:
soupette 2018-04-16 16:19:28 +02:00
parent 588363dcd7
commit 0f2ebfa997
17 changed files with 39 additions and 91 deletions

File diff suppressed because one or more lines are too long

View File

@ -100,8 +100,18 @@ if (process.env.npm_lifecycle_event === 'start') {
plugins.exist = true;
}
// Read `plugins` directory.
plugins.src = isAdmin && !plugins.exist ? fs.readdirSync(path.resolve(appPath, 'plugins')).filter(x => x[0] !== '.') : [];
// Read `plugins` directory and check if the plugin comes with an UI.
plugins.src = isAdmin && !plugins.exist ? fs.readdirSync(path.resolve(appPath, 'plugins')).filter(x => {
let hasAdminFolder;
try {
fs.accessSync(path.resolve(appPath, 'plugins', x, 'admin', 'src', 'containers', 'App'));
hasAdminFolder = true;
} catch(err) {
hasAdminFolder = false;
}
return x[0] !== '.' && hasAdminFolder;
}) : [];
// Construct object of plugin' paths.
plugins.folders = plugins.src.reduce((acc, current) => {

View File

@ -46,7 +46,18 @@ if (process.env.npm_lifecycle_event === 'start') {
plugins.exist = true;
}
plugins.src = process.env.IS_ADMIN === 'true' && !plugins.exist ? fs.readdirSync(path.resolve(appPath, 'plugins')).filter(x => x[0] !== '.') : [];
plugins.src = process.env.IS_ADMIN === 'true' && !plugins.exist ? fs.readdirSync(path.resolve(appPath, 'plugins')).filter(x => {
let hasAdminFolder;
try {
fs.accessSync(path.resolve(appPath, 'plugins', x, 'admin', 'src', 'containers', 'App'));
hasAdminFolder = true;
} catch(err) {
hasAdminFolder = false;
}
return x[0] !== '.' && hasAdminFolder;
}) : [];
plugins.folders = plugins.src.reduce((acc, current) => {
acc[current] = path.resolve(appPath, 'plugins', current, 'node_modules', 'strapi-helper-plugin', 'lib', 'src');

View File

@ -1,5 +0,0 @@
/*
*
* App actions
*
*/

View File

@ -1,5 +0,0 @@
/*
*
* App constants
*
*/

View File

@ -1,39 +0,0 @@
/**
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { Switch, Route } from 'react-router-dom';
import { bindActionCreators, compose } from 'redux';
class App extends React.Component {
render() {
return (
<div>
</div>
);
}
}
export function mapDispatchToProps(dispatch) {
return bindActionCreators(
{},
dispatch,
);
}
const mapStateToProps = createStructuredSelector({});
// Wrap the component to inject dispatch and state into it
const withConnect = connect(mapStateToProps, mapDispatchToProps);
export default compose(
withConnect,
)(App);

View File

@ -1,18 +0,0 @@
/*
*
* App reducer
*
*/
import { fromJS } from 'immutable';
const initialState = fromJS({});
function appReducer(state = initialState, action) {
switch (action.type) {
default:
return state;
}
}
export default appReducer;

View File

@ -1,9 +0,0 @@
// import { createSelector } from 'reselect';
/**
* Direct selector to the list state domain
*/
// const selectGlobalDomain = () => state => state.get('global');
export {};

View File

@ -30,9 +30,6 @@
"pluralize": "^7.0.0",
"strapi-utils": "3.0.0-alpha.11.3"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.11.3"
},
"author": {
"name": "A Strapi developer",
"email": "",

View File

@ -113,7 +113,20 @@ module.exports = function() {
}
// Create `plugins.json` file.
const data = Object.keys(this.plugins).map(name => ({
// Don't inject the plugins without an Admin
const data = Object.keys(this.plugins)
.filter(plugin => {
let hasAdminFolder;
try {
fs.accessSync(path.resolve(this.config.appPath, 'plugins', plugin, 'admin', 'src', 'containers', 'App'));
hasAdminFolder = true;
} catch(err) {
hasAdminFolder = false;
}
return hasAdminFolder;
})
.map(name => ({
id: name,
source: Object.keys(this.config.environments).reduce((acc, current) => {
const source = _.get(this.config.environments[current].server, 'admin.build.plugins.source', 'default');

View File

@ -130,7 +130,6 @@ watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-graphql');
watcher('', 'npm install ../strapi-utils --no-optional');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-graphql...', 'npm link --no-optional', false);