Merge branch 'master' into master

This commit is contained in:
Jørgensen 2018-02-02 08:04:42 +01:00 committed by GitHub
commit dffa0b03e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 184 additions and 95 deletions

View File

@ -88,21 +88,21 @@ _Reorganize the mono-repository. The rule to follow is to only have hooks withou
- ~~Improve generated APIs (especially the relation part)~~.
`strapi@alpha.8` *(expected release date: 22/12/2017)*:
- [Admin] Install plugins directly from the interface.
- Ask database settings during the project creation.
- Ping database before generating the project.
- Allow associations between app's models and plugins' models.
- ~~[Admin] Install plugins directly from the interface~~.
- ~~Ask database settings during the project creation~~.
- ~~Ping database before generating the project~~.
- ~~Allow associations between app's models and plugins' models~~.
`strapi@alpha.9` *(expected release date: 12/01/2018)*:
- [Plugin - Users & Permissions] Integrate providers authentication, email templates and advanced settings.
- ~~[Plugin] Analytics (homepage only)~~.
- ~~[Plugin - Users & Permissions] Integrate providers authentication, email templates and advanced settings~~.
`strapi@alpha.10` *(expected release date: 29/01/2018)*:
- [Plugin] Analytics.
`strapi@alpha.10` *(expected release date: 15/02/2018)*:
- [Framework] New core API to manage settings in database.
- [Admin] Refactor the Input component to make it more extensible.
`strapi@alpha.11` *(expected release date: 12/02/2018)*:
`strapi@alpha.11` *(expected release date: 02/03/2018)*:
- [Plugin] Upload.
- Re-design & improve the DX of the validations layer.
`strapi@alpha.12` *(expected release date: 02/03/2018)*:
- [Plugin] Media Library.
`strapi@alpha.12` *(expected release date: 19/03/2018)*:
- [Plugin] GraphQL.

View File

@ -54,3 +54,4 @@
### Migration
* [Migrating from v1 to v3](migration/migration-guide.md)
* [Migrating from 3.0.0-alpha.7.4 to 3.0.0-alpha.8](migration/migration-guide-alpha-7-4-to-alpha-8.md)
* [Migrating from 3.0.0-alpha.8 to 3.0.0-alpha.9](migration/migration-guide-alpha-8-to-alpha-9.md)

View File

@ -2,16 +2,19 @@
The middlewares are functions which are composed and executed in a stack-like manner upon request. If you are not familiar with the middleware stack in Koa, we highly recommend you to read the [Koa's documentation introduction](http://koajs.com/#introduction).
Enable the middleware in environments settings
**Path —** [`config/environments/**`]
```json
"urlReader": {
"enabled": true
}
```
**Path —** [`strapi/lib/middlewares/responseTime/index.js`](https://github.com/strapi/strapi/blob/master/packages/strapi/lib/middlewares/responseTime/index.js).
```js
module.exports = strapi => {
return {
defaults: {
responseTime: {
enabled: true
}
},
initialize: function(cb) {
strapi.app.use(async (ctx, next) => {
const start = Date.now();
@ -30,7 +33,6 @@ module.exports = strapi => {
};
```
- `defaults` (object): Contains the defaults configurations. This object is merged to `strapi.config.middleware.settings.**`.
- `initialize` (function): Called during the server boot. The callback `cb` needs to be called. Otherwise, the middleware won't be loaded into the stack.
The core of Strapi embraces a small list of middlewares for performances, security and great error handling.

View File

@ -0,0 +1,71 @@
# Migrating from 3.0.0-alpha.8 to 3.0.0-alpha.9
**Here are the major changes:**
- Put roles' permissions in database
- Providers connection (Facebook, GitHub, ...)
> Feel free to [join us on Slack](http://slack.strapi.io) and ask questions about the migration process.
## Getting started
Install Strapi `alpha.9` globally on your computer. To do so run `npm install strapi@3.0.0-alpha.9 -g`.
When it's done, generate a new empty project `strapi new myNewProject` (don't pay attention to the database configuration).
## Configurations
You will have to update just 2 files: `package.json` and `request.json`
- Edit the Strapi's dependencies version: (move Strapi's dependencies to `3.0.0-alpha.9` version) in `package.json` file
```json
{
"dependencies": {
"lodash": "4.x.x",
"strapi": "3.0.0-alpha.9",
"strapi-mongoose": "3.0.0-alpha.9"
}
}
```
- Edit the `session.enabled` settings to `true` in each environment file: `/configs/environments/***/request.json`
```json
{
"session": {
"enabled": true
}
}
```
## Update the Admin
Delete your old admin folder and replace it by the new one.
## Update the Plugins
Copy this file `/plugins/users-permissions/config/jwt.json` **from your old project** and paste it in the corresponding one in your new project.
Copy the fields and relations you had in your `/plugins/users-permissions/models/User.settings.json` file in the new one.
Then, delete your old `plugins` folder and replace it by the new one.
## ⚠️ Roles update
Roles are now stored in your database. You will have to re-create and configure them via the admin dashboard.
## ⚠️ User collection/table name has changed
If you have an existing set of users in your database you will have to rename the collection/table from `user` to `users-permissions_user`.
Then update all your users by changing the old role id by the new one which is in `users-permissions_role` collection/table.
That's all, you have now upgraded to Strapi `alpha.9`.

View File

@ -1,6 +1,6 @@
{
"private": true,
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"devDependencies": {
"assert": "~1.3.0",
"babel-eslint": "^6.1.2",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-admin",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Strapi Admin",
"repository": {
"type": "git",
@ -27,8 +27,8 @@
},
"devDependencies": {
"sanitize.css": "^4.1.0",
"strapi-helper-plugin": "3.0.0-alpha.8.3",
"strapi-utils": "3.0.0-alpha.8.3"
"strapi-helper-plugin": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi",

View File

@ -43,8 +43,6 @@ module.exports = function(strapi) {
initialize: cb => {
const connections = _.pickBy(strapi.config.connections, { connector: 'strapi-bookshelf' });
const done = _.after(_.size(connections), cb);
_.forEach(connections, (connection, connectionName) => {
// Apply defaults
_.defaults(connection.settings, strapi.config.hook.settings.bookshelf);
@ -70,11 +68,6 @@ module.exports = function(strapi) {
ORM.plugin('pagination');
}
// Select models concerned by this connection
const models = _.pickBy(strapi.models, { connection: connectionName });
// Will call the done() method when every models will be loaded.
const loadedHook = _.after(_.size(models), done);
const mountModels = (models, target, plugin = false) => {
// Parse every registered model.
_.forEach(models, (definition, model) => {
@ -205,7 +198,6 @@ module.exports = function(strapi) {
// Push attributes to be aware of model schema.
target[model]._attributes = definition.attributes;
loadedHook();
} catch (err) {
strapi.log.error('Impossible to register the `' + model + '` model.');
strapi.log.error(err);
@ -395,6 +387,8 @@ module.exports = function(strapi) {
mountModels(_.pickBy(strapi.plugins[name].models, { connection: connectionName }), plugin.models, name);
});
});
cb();
},
getQueryParams: (value, type, key) => {

View File

@ -1,6 +1,6 @@
{
"name": "strapi-bookshelf",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Bookshelf hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [
@ -19,8 +19,8 @@
"bookshelf": "^0.10.3",
"lodash": "^4.17.4",
"pluralize": "^6.0.0",
"strapi-knex": "3.0.0-alpha.8.3",
"strapi-utils": "3.0.0-alpha.8.3"
"strapi-knex": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.1"
},
"strapi": {
"isHook": true,

View File

@ -1,6 +1,6 @@
{
"name": "strapi-ejs",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "EJS hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-admin",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate the default admin panel for a Strapi application.",
"homepage": "http://strapi.io",
"keywords": [
@ -15,7 +15,7 @@
"dependencies": {
"fs-extra": "^4.0.1",
"lodash": "^4.17.4",
"strapi-admin": "3.0.0-alpha.8.3"
"strapi-admin": "3.0.0-alpha.9.1"
},
"author": {
"email": "hi@strapi.io",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-api",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate an API for a Strapi application.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-controller",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate a controller for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-model",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate a model for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -83,15 +83,33 @@ module.exports = (scope, cb) => {
// Install default plugins and link dependencies.
function pluginsInstallation() {
// Define the list of default plugins.
const defaultPlugins = ['settings-manager', 'content-type-builder', 'content-manager', 'users-permissions', 'email'];
const defaultPlugins = [{
name: 'settings-manager',
core: true
}, {
name: 'content-type-builder',
core: true
}, {
name: 'content-manager',
core: true
}, {
name: 'users-permissions',
core: true
}, {
name: 'email',
core: true
}, {
name: 'analytics',
core: false
}];
// Install each plugin.
defaultPlugins.forEach(defaultPlugin => {
try {
execSync(`node ${strapiBin} install ${defaultPlugin} ${scope.developerMode ? '--dev' : ''}`);
logger.info(`The plugin ${defaultPlugin} has been successfully installed.`);
execSync(`node ${strapiBin} install ${defaultPlugin.name} ${scope.developerMode && defaultPlugin.core ? '--dev' : ''}`);
logger.info(`The plugin ${defaultPlugin.name} has been successfully installed.`);
} catch (error) {
logger.error(`An error occurred during ${defaultPlugin} plugin installation.`);
logger.error(`An error occurred during ${defaultPlugin.name} plugin installation.`);
logger.error(error);
}
});

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-new",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate a new Strapi application.",
"homepage": "http://strapi.io",
"keywords": [
@ -18,7 +18,7 @@
"get-installed-path": "^3.0.1",
"inquirer": "^4.0.2",
"lodash": "^4.17.4",
"strapi-utils": "3.0.0-alpha.8.3",
"strapi-utils": "3.0.0-alpha.9.1",
"uuid": "^3.1.0"
},
"scripts": {

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-plugin",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate an plugin for a Strapi application.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-policy",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate a policy for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate-service",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Generate a service for a Strapi API.",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-generate",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Master of ceremonies for the Strapi generators.",
"homepage": "http://strapi.io",
"keywords": [
@ -17,7 +17,7 @@
"fs-extra": "^4.0.0",
"lodash": "^4.17.4",
"reportback": "^2.0.1",
"strapi-utils": "3.0.0-alpha.8.3"
"strapi-utils": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-helper-plugin",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Helper for Strapi plugins development",
"engines": {
"node": ">= 8.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-knex",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Knex hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-middleware-views",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Views hook to enable server-side rendering for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi-mongoose",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Mongoose hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [
@ -19,7 +19,7 @@
"mongoose": "^5.0.0-rc1",
"mongoose-float": "^1.0.2",
"pluralize": "^6.0.0",
"strapi-utils": "3.0.0-alpha.8.3"
"strapi-utils": "3.0.0-alpha.9.1"
},
"strapi": {
"isHook": true

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-content-manager",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "A powerful UI to easily manage your data.",
"strapi": {
"name": "Content Manager",
@ -24,7 +24,7 @@
},
"devDependencies": {
"react-select": "^1.0.0-rc.5",
"strapi-helper-plugin": "3.0.0-alpha.8.3"
"strapi-helper-plugin": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-content-type-builder",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Strapi plugin to create content type (API).",
"strapi": {
"name": "Content Type Builder",
@ -24,11 +24,11 @@
},
"dependencies": {
"pluralize": "^7.0.0",
"strapi-generate": "3.0.0-alpha.8.3",
"strapi-generate-api": "3.0.0-alpha.8.3"
"strapi-generate": "3.0.0-alpha.9.1",
"strapi-generate-api": "3.0.0-alpha.9.1"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.8.3"
"strapi-helper-plugin": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-email",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "This is the description of the plugin.",
"strapi": {
"name": "Email",
@ -26,7 +26,7 @@
"sendmail": "^1.2.0"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.8.3"
"strapi-helper-plugin": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi team",

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-settings-manager",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Strapi plugin to manage settings.",
"strapi": {
"name": "Settings Manager",
@ -25,7 +25,7 @@
"devDependencies": {
"flag-icon-css": "^2.8.0",
"react-select": "^1.0.0-rc.5",
"strapi-helper-plugin": "3.0.0-alpha.8.3"
"strapi-helper-plugin": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi team",

View File

@ -70,6 +70,10 @@ module.exports = {
});
}
} else {
if (!_.get(strapi.plugins['users-permissions'].config.grant[provider], 'enabled')) {
return ctx.badRequest(null, 'This provider is disabled.');
}
// Connect the user thanks to the third-party provider.
let user, error;
try {

View File

@ -1,6 +1,6 @@
{
"name": "strapi-plugin-users-permissions",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Protect your API with a full-authentication process based on JWT",
"strapi": {
"name": "Auth & Permissions",
@ -32,7 +32,7 @@
"uuid": "^3.1.0"
},
"devDependencies": {
"strapi-helper-plugin": "3.0.0-alpha.8.3"
"strapi-helper-plugin": "3.0.0-alpha.9.1"
},
"author": {
"name": "Strapi team",

View File

@ -45,35 +45,34 @@ exports.connect = (provider, query) => {
}
try {
const user = await strapi.query('user', 'users-permissions').findOne({email: profile.email});
const users = await strapi.query('user', 'users-permissions').find({
email: profile.email
});
if (!strapi.plugins['users-permissions'].config.advanced.allow_register) {
if (_.isEmpty(_.find(users, {provider})) && !strapi.plugins['users-permissions'].config.advanced.allow_register) {
return resolve([null, [{ messages: [{ id: 'Auth.advanced.allow_register' }] }], 'Register action is actualy not available.']);
}
if (user && user.provider === provider) {
if (!_.isEmpty(_.find(users, {provider}))) {
return resolve([user, null]);
}
if (user && user.provider !== provider && strapi.plugins['users-permissions'].config.advanced.unique_email) {
if (!_.isEmpty(_.find(users, user => user.provider !== provider)) && strapi.plugins['users-permissions'].config.advanced.unique_email) {
return resolve([null, [{ messages: [{ id: 'Auth.form.error.email.taken' }] }], 'Email is already taken.']);
}
if (!user || _.get(user, 'provider') !== provider) {
// Retrieve role `guest`.
const guest = await strapi.query('role', 'users-permissions').findOne({ type: 'guest' }, []);
// Retrieve role `guest`.
const guest = await strapi.query('role', 'users-permissions').findOne({ type: 'guest' }, []);
// Create the new user.
const params = _.assign(profile, {
provider: provider,
role: guest._id || guest.id
});
// Create the new user.
const params = _.assign(profile, {
provider: provider,
role: guest._id || guest.id
});
const createdUser = await strapi.query('user', 'users-permissions').create(params);
const createdUser = await strapi.query('user', 'users-permissions').create(params);
return resolve([createdUser, null]);
}
resolve([user, null]);
return resolve([createdUser, null]);
} catch (err) {
reject([null, err]);
}

View File

@ -1,6 +1,6 @@
{
"name": "strapi-redis",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Redis hook for the Strapi framework",
"homepage": "http://strapi.io",
"keywords": [
@ -18,7 +18,7 @@
"ioredis": "^3.1.2",
"lodash": "^4.17.4",
"stack-trace": "0.0.10",
"strapi-utils": "3.0.0-alpha.8.3"
"strapi-utils": "3.0.0-alpha.9.1"
},
"strapi": {
"isHook": true

View File

@ -1,6 +1,6 @@
{
"name": "strapi-utils",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "Shared utilities for the Strapi packages",
"homepage": "http://strapi.io",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "strapi",
"version": "3.0.0-alpha.8.3",
"version": "3.0.0-alpha.9.1",
"description": "An open source solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier.",
"homepage": "http://strapi.io",
"keywords": [
@ -55,14 +55,14 @@
"rimraf": "^2.6.2",
"semver": "^5.4.1",
"stack-trace": "0.0.10",
"strapi-generate": "3.0.0-alpha.8.3",
"strapi-generate-admin": "3.0.0-alpha.8.3",
"strapi-generate-api": "3.0.0-alpha.8.3",
"strapi-generate-new": "3.0.0-alpha.8.3",
"strapi-generate-plugin": "3.0.0-alpha.8.3",
"strapi-generate-policy": "3.0.0-alpha.8.3",
"strapi-generate-service": "3.0.0-alpha.8.3",
"strapi-utils": "3.0.0-alpha.8.3"
"strapi-generate": "3.0.0-alpha.9.1",
"strapi-generate-admin": "3.0.0-alpha.9.1",
"strapi-generate-api": "3.0.0-alpha.9.1",
"strapi-generate-new": "3.0.0-alpha.9.1",
"strapi-generate-plugin": "3.0.0-alpha.9.1",
"strapi-generate-policy": "3.0.0-alpha.9.1",
"strapi-generate-service": "3.0.0-alpha.9.1",
"strapi-utils": "3.0.0-alpha.9.1"
},
"author": {
"email": "hi@strapi.io",