Init plugin upload

Created the upload plugin and install it by default
This commit is contained in:
cyril lopez 2018-02-08 12:01:06 +01:00
parent eb6702ecf3
commit ecd12c451a
25 changed files with 476 additions and 0 deletions

View File

@ -98,6 +98,9 @@ module.exports = (scope, cb) => {
}, {
name: 'email',
core: true
},{
name: 'upload',
core: true
}, {
name: 'analytics',
core: false

View File

@ -0,0 +1,7 @@
root = true
[*]
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 2

103
packages/strapi-upload/.gitattributes vendored Executable file
View File

@ -0,0 +1,103 @@
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
#
# The above will handle all files NOT found below
#
#
## These files are text and should be normalized (Convert crlf => lf)
#
# source code
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text eol=lf
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.svg text
*.txt text
*.ini text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text
*.sh text
*.bat text
# templates
*.ejs text
*.hbt text
*.jade text
*.haml text
*.hbs text
*.dot text
*.tmpl text
*.phtml text
# git config
.gitattributes text
.gitignore text
.gitconfig text
# code analysis config
.jshintrc text
.jscsrc text
.jshintignore text
.csslintrc text
# misc config
*.yaml text
*.yml text
.editorconfig text
# build config
*.npmignore text
*.bowerrc text
# Heroku
Procfile text
.slugignore text
# Documentation
*.md text
LICENSE text
AUTHORS text
#
## These files are binary and should be left untouched
#
# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary

10
packages/strapi-upload/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# Don't check auto-generated stuff into git
coverage
node_modules
stats.json
package-lock.json
# Cruft
.DS_Store
npm-debug.log
.idea

View File

@ -0,0 +1 @@
# Strapi plugin

View File

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

View File

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

View File

@ -0,0 +1,57 @@
/**
*
* 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';
// Utils
import { pluginId } from 'app';
// Containers
import HomePage from 'containers/HomePage';
import NotFoundPage from 'containers/NotFoundPage';
class App extends React.Component {
render() {
return (
<div className={pluginId}>
<Switch>
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
<Route component={NotFoundPage} />
</Switch>
</div>
);
}
}
App.contextTypes = {
plugins: PropTypes.object,
router: PropTypes.object.isRequired,
updatePlugin: PropTypes.func,
};
App.propTypes = {};
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

@ -0,0 +1,18 @@
/*
*
* 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

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

View File

@ -0,0 +1,13 @@
/*
*
* HomePage actions
*
*/
import { DEFAULT_ACTION } from './constants';
export function defaultAction() {
return {
type: DEFAULT_ACTION,
};
}

View File

@ -0,0 +1,7 @@
/*
*
* HomePage constants
*
*/
export const DEFAULT_ACTION = 'HomePage/DEFAULT_ACTION';

View File

@ -0,0 +1,65 @@
/*
*
* HomePage
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { injectIntl } from 'react-intl';
import { bindActionCreators, compose } from 'redux';
import injectReducer from 'utils/injectReducer';
import injectSaga from 'utils/injectSaga';
// Selectors
import selectHomePage from './selectors';
// Styles
import styles from './styles.scss';
import reducer from './reducer';
import saga from './saga';
export class HomePage extends React.Component {
render() {
return (
<div className={styles.homePage}>
</div>
);
}
}
HomePage.contextTypes = {
router: PropTypes.object,
};
HomePage.propTypes = {
// homePage: PropTypes.object,
};
function mapDispatchToProps(dispatch) {
return bindActionCreators(
{
// Your actions here
},
dispatch,
);
}
const mapStateToProps = createStructuredSelector({
homePage: selectHomePage(),
});
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withReducer = injectReducer({ key: 'homePage', reducer });
const withSaga = injectSaga({ key: 'homePage', saga });
export default compose(
withReducer,
withSaga,
withConnect,
)(injectIntl(HomePage));

View File

@ -0,0 +1,22 @@
/*
*
* HomePage reducer
*
*/
import { fromJS } from 'immutable';
import { DEFAULT_ACTION } from './constants';
const initialState = fromJS({});
function homePageReducer(state = initialState, action) {
switch (action.type) {
case DEFAULT_ACTION:
return state;
default:
return state;
}
}
export default homePageReducer;

View File

@ -0,0 +1,9 @@
// import { LOCATION_CHANGE } from 'react-router-redux';
// import { takeLatest, put, fork, take, cancel } from 'redux-saga/effects';
// Individual exports for testing
export function* defaultSaga() {
}
// All sagas to be loaded
export default defaultSaga;

View File

@ -0,0 +1,17 @@
import { createSelector } from 'reselect';
/**
* Direct selector to the homePage state domain
*/
const selectHomePageDomain = () => state => state.get('homePage');
/**
* Default selector used by HomePage
*/
const selectHomePage = () => createSelector(
selectHomePageDomain(),
(substate) => substate.toJS(),
);
export default selectHomePage;

View File

@ -0,0 +1,3 @@
.homePage {
}

View File

@ -0,0 +1,20 @@
/**
* NotFoundPage
*
* This is the page we show when the user visits a url that doesn't have a route
*
* NOTE: while this component should technically be a stateless functional
* component (SFC), hot reloading does not currently support SFCs. If hot
* reloading is not a neccessity for you then you can refactor it and remove
* the linting exception.
*/
import React from 'react';
import NotFound from 'components/NotFound';
export default class NotFoundPage extends React.Component {
render() {
return <NotFound {...this.props} />;
}
}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,12 @@
{
"routes": [
{
"method": "GET",
"path": "/",
"handler": "Upload.index",
"config": {
"policies": []
}
}
]
}

View File

@ -0,0 +1,25 @@
'use strict';
/**
* Upload.js controller
*
* @description: A set of functions called "actions" of the `upload` plugin.
*/
module.exports = {
/**
* Default action.
*
* @return {Object}
*/
index: async (ctx) => {
// Add your own logic here.
// Send 200 `ok`
ctx.send({
message: 'ok'
});
}
};

View File

@ -0,0 +1,46 @@
{
"name": "strapi-plugin-upload",
"version": "0.0.0",
"description": "This is the description of the plugin.",
"strapi": {
"name": "upload",
"icon": "plug",
"description": "Description of upload plugin."
},
"scripts": {
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",
"start": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/lib/server",
"generate": "node ./node_modules/plop/plop.js --plopfile node_modules/strapi-helper-plugin/lib/internals/generators/index.js",
"lint": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern '/admin/build/' --config ./node_modules/strapi-helper-plugin/lib/internals/eslint/.eslintrc.json admin",
"prettier": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/prettier --single-quote --trailing-comma es5 --write \"{admin,__{tests,mocks}__}/**/*.js\"",
"test": "npm run lint",
"prepublishOnly": "npm run build"
},
"dependencies": {},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.9.2"
},
"author": {
"name": "A Strapi developer",
"email": "",
"url": ""
},
"maintainers": [
{
"name": "A Strapi developer",
"email": "",
"url": ""
}
],
"engines": {
"node": ">= 7.0.0",
"npm": ">= 3.0.0"
},
"license": "MIT"
}

View File

@ -0,0 +1,11 @@
'use strict';
/**
* Upload.js service
*
* @description: A set of functions similar to controller's actions to avoid code duplication.
*/
module.exports = {
};

View File

@ -99,6 +99,12 @@ shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-settings-manager...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-upload');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-upload...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-content-type-builder');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
watcher('', 'npm install ../strapi-generate --no-optional');