From cf8184e2233c65cde3fdeb373d82015d79330e16 Mon Sep 17 00:00:00 2001 From: Jim LAURIE Date: Wed, 11 Jul 2018 16:23:14 +0200 Subject: [PATCH] Use hook prefix and rename --- docs/3.x.x/en/advanced/hooks.md | 10 +++---- docs/3.x.x/en/advanced/usage-tracking.md | 2 +- .../3.x.x/en/configurations/configurations.md | 10 +++---- .../templates/bookshelf/service.template | 2 +- .../environments/production/database.json | 2 +- .../config/environments/staging/database.json | 2 +- packages/strapi-generate-new/lib/before.js | 14 +++++----- .../.gitignore | 0 .../.npmignore | 0 .../LICENSE.md | 0 .../README.md | 12 ++++----- .../lib/index.js | 2 +- .../lib/relations.js | 0 .../lib/utils/connectivity.js | 0 .../lib/utils/graphql.js | 0 .../lib/utils/index.js | 0 .../package.json | 7 +++-- .../.editorconfig | 0 .../.gitignore | 0 .../.npmignore | 0 .../LICENSE.md | 0 .../{strapi-ejs => strapi-hook-ejs}/README.md | 0 .../lib/index.js | 0 .../package.json | 5 +--- .../.editorconfig | 0 .../.gitignore | 0 .../.npmignore | 0 .../LICENSE.md | 0 .../README.md | 10 +++---- .../lib/index.js | 2 +- .../package.json | 5 +--- .../.editorconfig | 0 .../.gitignore | 0 .../.npmignore | 0 .../LICENSE.md | 0 .../README.md | 10 +++---- .../lib/index.js | 2 +- .../lib/relations.js | 2 +- .../lib/utils/connectivity.js | 0 .../lib/utils/index.js | 0 .../package.json | 5 +--- .../.editorconfig | 0 .../.gitignore | 0 .../.npmignore | 0 .../LICENSE.md | 0 .../README.md | 0 .../lib/index.js | 4 +-- .../lib/utils/connectivity.js | 0 .../package.json | 5 +--- packages/strapi-middleware-views/package.json | 5 +--- .../controllers/ContentTypeBuilder.js | 2 +- .../services/ContentTypeBuilder.js | 2 +- .../services/SettingsManager.js | 8 +++--- packages/strapi-utils/lib/knex.js | 4 +-- packages/strapi/lib/core/configurations.js | 8 +++--- packages/strapi/lib/core/hooks.js | 27 +++---------------- packages/strapi/lib/hooks/index.js | 2 +- scripts/setup.js | 14 +++++----- 58 files changed, 75 insertions(+), 110 deletions(-) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/.gitignore (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/.npmignore (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/LICENSE.md (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/README.md (62%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/lib/index.js (99%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/lib/relations.js (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/lib/utils/connectivity.js (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/lib/utils/graphql.js (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/lib/utils/index.js (100%) rename packages/{strapi-bookshelf => strapi-hook-bookshelf}/package.json (90%) rename packages/{strapi-ejs => strapi-hook-ejs}/.editorconfig (100%) rename packages/{strapi-ejs => strapi-hook-ejs}/.gitignore (100%) rename packages/{strapi-ejs => strapi-hook-ejs}/.npmignore (100%) rename packages/{strapi-ejs => strapi-hook-ejs}/LICENSE.md (100%) rename packages/{strapi-ejs => strapi-hook-ejs}/README.md (100%) rename packages/{strapi-ejs => strapi-hook-ejs}/lib/index.js (100%) rename packages/{strapi-ejs => strapi-hook-ejs}/package.json (93%) rename packages/{strapi-knex => strapi-hook-knex}/.editorconfig (100%) rename packages/{strapi-knex => strapi-hook-knex}/.gitignore (100%) rename packages/{strapi-knex => strapi-hook-knex}/.npmignore (100%) rename packages/{strapi-knex => strapi-hook-knex}/LICENSE.md (100%) rename packages/{strapi-knex => strapi-hook-knex}/README.md (65%) rename packages/{strapi-knex => strapi-hook-knex}/lib/index.js (98%) rename packages/{strapi-knex => strapi-hook-knex}/package.json (93%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/.editorconfig (100%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/.gitignore (100%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/.npmignore (100%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/LICENSE.md (100%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/README.md (52%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/lib/index.js (99%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/lib/relations.js (99%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/lib/utils/connectivity.js (100%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/lib/utils/index.js (100%) rename packages/{strapi-mongoose => strapi-hook-mongoose}/package.json (93%) rename packages/{strapi-redis => strapi-hook-redis}/.editorconfig (100%) rename packages/{strapi-redis => strapi-hook-redis}/.gitignore (100%) rename packages/{strapi-redis => strapi-hook-redis}/.npmignore (100%) rename packages/{strapi-redis => strapi-hook-redis}/LICENSE.md (100%) rename packages/{strapi-redis => strapi-hook-redis}/README.md (100%) rename packages/{strapi-redis => strapi-hook-redis}/lib/index.js (98%) rename packages/{strapi-redis => strapi-hook-redis}/lib/utils/connectivity.js (100%) rename packages/{strapi-redis => strapi-hook-redis}/package.json (93%) diff --git a/docs/3.x.x/en/advanced/hooks.md b/docs/3.x.x/en/advanced/hooks.md index 972ade67f0..eb4e5dbfbf 100644 --- a/docs/3.x.x/en/advanced/hooks.md +++ b/docs/3.x.x/en/advanced/hooks.md @@ -1,6 +1,6 @@ # Hooks -The hooks are modules that add functionality to the core. They are loaded during the server boot. For example, if your project needs to work with a SQL database, your will have to add the hook `strapi-bookshelf` to be able to connect your app with your database. +The hooks are modules that add functionality to the core. They are loaded during the server boot. For example, if your project needs to work with a SQL database, your will have to add the hook `strapi-hook-bookshelf` to be able to connect your app with your database. **Path —** `./hooks/documentation/lib/index.js`. ```js @@ -76,13 +76,13 @@ The `index.js` is the entry point to your hook. It should look like the example ## Dependencies -It happens that a hook has a dependency to another one. For example, the `strapi-bookshelf` has a dependency to `strapi-knex`. Without it, the `strapi-bookshelf` can't work correctly. It also means that the `strapi-knex` hook has to be loaded before. +It happens that a hook has a dependency to another one. For example, the `strapi-hook-bookshelf` has a dependency to `strapi-hook-knex`. Without it, the `strapi-hook-bookshelf` can't work correctly. It also means that the `strapi-hook-knex` hook has to be loaded before. To handle this case, you need to update the `package.json` at the root of your hook. ```json { - "name": "strapi-bookshelf", + "name": "strapi-hook-bookshelf", "version": "x.x.x", "description": "Bookshelf hook for the Strapi framework", "dependencies": { @@ -90,10 +90,10 @@ To handle this case, you need to update the `package.json` at the root of your h }, "strapi": { "dependencies": [ - "strapi-knex" + "strapi-hook-knex" ] } -} +} ``` ## Custom hooks diff --git a/docs/3.x.x/en/advanced/usage-tracking.md b/docs/3.x.x/en/advanced/usage-tracking.md index b9a84d0e58..b6b445700f 100644 --- a/docs/3.x.x/en/advanced/usage-tracking.md +++ b/docs/3.x.x/en/advanced/usage-tracking.md @@ -13,7 +13,7 @@ Here is the list of the collected data and why we need them. *Understand how the developers are using the different configurations? How many projects are started in production mode?* - **Node modules names** *Are developers integrating Strapi with Stripe? It means that we should develop a plugin to simplify the development process with Stripe. - Are developers using Strapi with strapi-bookshelf or strapi-mongoose? It helps us prioritize the issues.* + Are developers using Strapi with strapi-hook-bookshelf or strapi-hook-mongoose? It helps us prioritize the issues.* - **OS** *Is the community using Windows, Linux or Mac? It helps us prioritize the issues.* - **Build configurations** diff --git a/docs/3.x.x/en/configurations/configurations.md b/docs/3.x.x/en/configurations/configurations.md index d038fc99ec..ced94dd32b 100644 --- a/docs/3.x.x/en/configurations/configurations.md +++ b/docs/3.x.x/en/configurations/configurations.md @@ -164,7 +164,7 @@ Most of the application's configurations are defined by environment. It means th - `defaultConnection` (string): Connection by default for models which are not related to a specific `connection`. Default value: `default`. - `connections` List of all available connections. - `default` - - `connector` (string): Connector used by the current connection. Default value: `strapi-mongoose`. + - `connector` (string): Connector used by the current connection. Default value: `strapi-hook-mongoose`. - `client` (string): Client used to store session. Default value: `cookie`. - `key` (string): Cookie key name. Default value: `strapi.sid` - `maxAge` (integer): Time in milliseconds before the session expire. Default value: `86400000`. @@ -192,7 +192,7 @@ Most of the application's configurations are defined by environment. It means th "defaultConnection": "default", "connections": { "default": { - "connector": "strapi-mongoose", + "connector": "strapi-hook-mongoose", "settings": { "client": "mongo", "host": "localhost", @@ -208,7 +208,7 @@ Most of the application's configurations are defined by environment. It means th } }, "postgres": { - "connector": "strapi-bookshelf", + "connector": "strapi-hook-bookshelf", "settings": { "client": "postgres", "host": "localhost", @@ -223,7 +223,7 @@ Most of the application's configurations are defined by environment. It means th } }, "mysql": { - "connector": "strapi-bookshelf", + "connector": "strapi-hook-bookshelf", "settings": { "client": "mysql", "host": "localhost", @@ -367,7 +367,7 @@ In any JSON configurations files in your project, you can inject dynamic values "defaultConnection": "default", "connections": { "default": { - "connector": "strapi-mongoose", + "connector": "strapi-hook-mongoose", "settings": { "client": "mongo", "uri": "${process.env.DATABASE_URI || ''}", diff --git a/packages/strapi-generate-api/templates/bookshelf/service.template b/packages/strapi-generate-api/templates/bookshelf/service.template index 0685e6362e..948a990494 100755 --- a/packages/strapi-generate-api/templates/bookshelf/service.template +++ b/packages/strapi-generate-api/templates/bookshelf/service.template @@ -10,7 +10,7 @@ const _ = require('lodash'); // Strapi utilities. -const utils = require('strapi-bookshelf/lib/utils/'); +const utils = require('strapi-hook-bookshelf/lib/utils/'); module.exports = { diff --git a/packages/strapi-generate-new/files/config/environments/production/database.json b/packages/strapi-generate-new/files/config/environments/production/database.json index 287a8121e0..3075fabf91 100755 --- a/packages/strapi-generate-new/files/config/environments/production/database.json +++ b/packages/strapi-generate-new/files/config/environments/production/database.json @@ -2,7 +2,7 @@ "defaultConnection": "default", "connections": { "default": { - "connector": "strapi-mongoose", + "connector": "strapi-hook-mongoose", "settings": { "client": "mongo", "uri": "${process.env.DATABASE_URI || ''}", diff --git a/packages/strapi-generate-new/files/config/environments/staging/database.json b/packages/strapi-generate-new/files/config/environments/staging/database.json index ec7c26da4c..43edf2421d 100755 --- a/packages/strapi-generate-new/files/config/environments/staging/database.json +++ b/packages/strapi-generate-new/files/config/environments/staging/database.json @@ -2,7 +2,7 @@ "defaultConnection": "default", "connections": { "default": { - "connector": "strapi-mongoose", + "connector": "strapi-hook-mongoose", "settings": { "client": "mongo", "uri": "${process.env.DATABASE_URI || ''}", diff --git a/packages/strapi-generate-new/lib/before.js b/packages/strapi-generate-new/lib/before.js index 9ad9e8c985..f15d6c514d 100755 --- a/packages/strapi-generate-new/lib/before.js +++ b/packages/strapi-generate-new/lib/before.js @@ -69,14 +69,14 @@ module.exports = (scope, cb) => { name: 'MongoDB (recommended)', value: { database: 'mongo', - connector: 'strapi-mongoose' + connector: 'strapi-hook-mongoose' } }, { name: 'Postgres', value: { database: 'postgres', - connector: 'strapi-bookshelf', + connector: 'strapi-hook-bookshelf', module: 'pg' } }, @@ -84,7 +84,7 @@ module.exports = (scope, cb) => { name: 'MySQL', value: { database: 'mysql', - connector: 'strapi-bookshelf', + connector: 'strapi-hook-bookshelf', module: 'mysql' } } @@ -223,10 +223,10 @@ module.exports = (scope, cb) => { cmd += ` ${scope.client.module}`; } - if (scope.client.connector === 'strapi-bookshelf') { - cmd += ` strapi-knex@alpha`; + if (scope.client.connector === 'strapi-hook-bookshelf') { + cmd += ` strapi-hook-knex@alpha`; - scope.additionalsDependencies = ['strapi-knex', 'knex']; + scope.additionalsDependencies = ['strapi-hook-knex', 'knex']; } exec(cmd, () => { @@ -234,7 +234,7 @@ module.exports = (scope, cb) => { const lock = require(path.join(`${scope.tmpPath}`,`/node_modules/`,`${scope.client.module}/package.json`)); scope.client.version = lock.version; - if (scope.developerMode === true && scope.client.connector === 'strapi-bookshelf') { + if (scope.developerMode === true && scope.client.connector === 'strapi-hook-bookshelf') { const knexVersion = require(path.join(`${scope.tmpPath}`,`/node_modules/`,`knex/package.json`)); scope.additionalsDependencies[1] = `knex@${knexVersion.version || 'latest'}`; } diff --git a/packages/strapi-bookshelf/.gitignore b/packages/strapi-hook-bookshelf/.gitignore similarity index 100% rename from packages/strapi-bookshelf/.gitignore rename to packages/strapi-hook-bookshelf/.gitignore diff --git a/packages/strapi-bookshelf/.npmignore b/packages/strapi-hook-bookshelf/.npmignore similarity index 100% rename from packages/strapi-bookshelf/.npmignore rename to packages/strapi-hook-bookshelf/.npmignore diff --git a/packages/strapi-bookshelf/LICENSE.md b/packages/strapi-hook-bookshelf/LICENSE.md similarity index 100% rename from packages/strapi-bookshelf/LICENSE.md rename to packages/strapi-hook-bookshelf/LICENSE.md diff --git a/packages/strapi-bookshelf/README.md b/packages/strapi-hook-bookshelf/README.md similarity index 62% rename from packages/strapi-bookshelf/README.md rename to packages/strapi-hook-bookshelf/README.md index 5d1ce7ecb7..6e67c8c6f4 100755 --- a/packages/strapi-bookshelf/README.md +++ b/packages/strapi-hook-bookshelf/README.md @@ -1,12 +1,12 @@ -# strapi-bookshelf +# strapi-boohook-kshelf -[![npm version](https://img.shields.io/npm/v/strapi-bookshelf.svg)](https://www.npmjs.org/package/strapi-bookshelf) -[![npm downloads](https://img.shields.io/npm/dm/strapi-bookshelf.svg)](https://www.npmjs.org/package/strapi-bookshelf) -[![npm dependencies](https://david-dm.org/strapi/strapi-bookshelf.svg)](https://david-dm.org/strapi/strapi-bookshelf) -[![Build status](https://travis-ci.org/strapi/strapi-bookshelf.svg?branch=master)](https://travis-ci.org/strapi/strapi-bookshelf) +[![npm version](https://img.shields.io/npm/v/strapi-hook-bookshelf.svg)](https://www.npmjs.org/package/strapi-hook-bookshelf) +[![npm downloads](https://img.shields.io/npm/dm/strapi-hook-bookshelf.svg)](https://www.npmjs.org/package/strapi-hook-bookshelf) +[![npm dependencies](https://david-dm.org/strapi/strapi-hook-bookshelf.svg)](https://david-dm.org/strapi/strapi-hook-bookshelf) +[![Build status](https://travis-ci.org/strapi/strapi-hook-bookshelf.svg?branch=master)](https://travis-ci.org/strapi/strapi-hook-bookshelf) [![Slack status](http://strapi-slack.herokuapp.com/badge.svg)](http://slack.strapi.io) -This built-in hook allows you to use the [Bookshelf ORM](http://bookshelfjs.org/) using the `strapi-knex` hook. +This built-in hook allows you to use the [Bookshelf ORM](http://bookshelfjs.org/) using the `strapi-hook-knex` hook. [Bookshelf ORM](http://bookshelfjs.org/) is a JavaScript ORM for Node.js, built on the [Knex node module](http://knexjs.org/) SQL query builder. Featuring both promise based and traditional callback interfaces, providing transaction support, eager/nested-eager relation loading, polymorphic associations, and support for one-to-one, one-to-many, and many-to-many relations. diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-hook-bookshelf/lib/index.js similarity index 99% rename from packages/strapi-bookshelf/lib/index.js rename to packages/strapi-hook-bookshelf/lib/index.js index d73418eba4..39214f7cc8 100755 --- a/packages/strapi-bookshelf/lib/index.js +++ b/packages/strapi-hook-bookshelf/lib/index.js @@ -45,7 +45,7 @@ module.exports = function(strapi) { */ initialize: async cb => { - const connections = _.pickBy(strapi.config.connections, { connector: 'strapi-bookshelf' }); + const connections = _.pickBy(strapi.config.connections, { connector: 'strapi-hook-bookshelf' }); const databaseUpdate = []; diff --git a/packages/strapi-bookshelf/lib/relations.js b/packages/strapi-hook-bookshelf/lib/relations.js similarity index 100% rename from packages/strapi-bookshelf/lib/relations.js rename to packages/strapi-hook-bookshelf/lib/relations.js diff --git a/packages/strapi-bookshelf/lib/utils/connectivity.js b/packages/strapi-hook-bookshelf/lib/utils/connectivity.js similarity index 100% rename from packages/strapi-bookshelf/lib/utils/connectivity.js rename to packages/strapi-hook-bookshelf/lib/utils/connectivity.js diff --git a/packages/strapi-bookshelf/lib/utils/graphql.js b/packages/strapi-hook-bookshelf/lib/utils/graphql.js similarity index 100% rename from packages/strapi-bookshelf/lib/utils/graphql.js rename to packages/strapi-hook-bookshelf/lib/utils/graphql.js diff --git a/packages/strapi-bookshelf/lib/utils/index.js b/packages/strapi-hook-bookshelf/lib/utils/index.js similarity index 100% rename from packages/strapi-bookshelf/lib/utils/index.js rename to packages/strapi-hook-bookshelf/lib/utils/index.js diff --git a/packages/strapi-bookshelf/package.json b/packages/strapi-hook-bookshelf/package.json similarity index 90% rename from packages/strapi-bookshelf/package.json rename to packages/strapi-hook-bookshelf/package.json index 7b3117939d..ea37786086 100755 --- a/packages/strapi-bookshelf/package.json +++ b/packages/strapi-hook-bookshelf/package.json @@ -1,5 +1,5 @@ { - "name": "strapi-bookshelf", + "name": "strapi-hook-bookshelf", "version": "3.0.0-alpha.12.7.1", "description": "Bookshelf hook for the Strapi framework", "homepage": "http://strapi.io", @@ -20,13 +20,12 @@ "inquirer": "^5.2.0", "lodash": "^4.17.4", "pluralize": "^6.0.0", - "strapi-knex": "3.0.0-alpha.12.7.1", + "strapi-hook-knex": "3.0.0-alpha.12.7.1", "strapi-utils": "3.0.0-alpha.12.7.1" }, "strapi": { - "isHook": true, "dependencies": [ - "strapi-knex" + "strapi-hook-knex" ] }, "scripts": { diff --git a/packages/strapi-ejs/.editorconfig b/packages/strapi-hook-ejs/.editorconfig similarity index 100% rename from packages/strapi-ejs/.editorconfig rename to packages/strapi-hook-ejs/.editorconfig diff --git a/packages/strapi-ejs/.gitignore b/packages/strapi-hook-ejs/.gitignore similarity index 100% rename from packages/strapi-ejs/.gitignore rename to packages/strapi-hook-ejs/.gitignore diff --git a/packages/strapi-ejs/.npmignore b/packages/strapi-hook-ejs/.npmignore similarity index 100% rename from packages/strapi-ejs/.npmignore rename to packages/strapi-hook-ejs/.npmignore diff --git a/packages/strapi-ejs/LICENSE.md b/packages/strapi-hook-ejs/LICENSE.md similarity index 100% rename from packages/strapi-ejs/LICENSE.md rename to packages/strapi-hook-ejs/LICENSE.md diff --git a/packages/strapi-ejs/README.md b/packages/strapi-hook-ejs/README.md similarity index 100% rename from packages/strapi-ejs/README.md rename to packages/strapi-hook-ejs/README.md diff --git a/packages/strapi-ejs/lib/index.js b/packages/strapi-hook-ejs/lib/index.js similarity index 100% rename from packages/strapi-ejs/lib/index.js rename to packages/strapi-hook-ejs/lib/index.js diff --git a/packages/strapi-ejs/package.json b/packages/strapi-hook-ejs/package.json similarity index 93% rename from packages/strapi-ejs/package.json rename to packages/strapi-hook-ejs/package.json index 110ec9b2c3..8d2e9af34f 100755 --- a/packages/strapi-ejs/package.json +++ b/packages/strapi-hook-ejs/package.json @@ -1,5 +1,5 @@ { - "name": "strapi-ejs", + "name": "strapi-hook-ejs", "version": "3.0.0-alpha.12.7.1", "description": "EJS hook for the Strapi framework", "homepage": "http://strapi.io", @@ -16,9 +16,6 @@ "co": "^4.6.0", "koa-ejs": "^4.1.0" }, - "strapi": { - "isHook": true - }, "scripts": { "prepublishOnly": "npm prune" }, diff --git a/packages/strapi-knex/.editorconfig b/packages/strapi-hook-knex/.editorconfig similarity index 100% rename from packages/strapi-knex/.editorconfig rename to packages/strapi-hook-knex/.editorconfig diff --git a/packages/strapi-knex/.gitignore b/packages/strapi-hook-knex/.gitignore similarity index 100% rename from packages/strapi-knex/.gitignore rename to packages/strapi-hook-knex/.gitignore diff --git a/packages/strapi-knex/.npmignore b/packages/strapi-hook-knex/.npmignore similarity index 100% rename from packages/strapi-knex/.npmignore rename to packages/strapi-hook-knex/.npmignore diff --git a/packages/strapi-knex/LICENSE.md b/packages/strapi-hook-knex/LICENSE.md similarity index 100% rename from packages/strapi-knex/LICENSE.md rename to packages/strapi-hook-knex/LICENSE.md diff --git a/packages/strapi-knex/README.md b/packages/strapi-hook-knex/README.md similarity index 65% rename from packages/strapi-knex/README.md rename to packages/strapi-hook-knex/README.md index 694ced22bb..eb8fbb5470 100755 --- a/packages/strapi-knex/README.md +++ b/packages/strapi-hook-knex/README.md @@ -1,9 +1,9 @@ -# strapi-knex +# strapi-hook-knex -[![npm version](https://img.shields.io/npm/v/strapi-knex.svg)](https://www.npmjs.org/package/strapi-knex) -[![npm downloads](https://img.shields.io/npm/dm/strapi-knex.svg)](https://www.npmjs.org/package/strapi-knex) -[![npm dependencies](https://david-dm.org/strapi/strapi-knex.svg)](https://david-dm.org/strapi/strapi-knex) -[![Build status](https://travis-ci.org/strapi/strapi-knex.svg?branch=master)](https://travis-ci.org/strapi/strapi-knex) +[![npm version](https://img.shields.io/npm/v/strapi-hook-knex.svg)](https://www.npmjs.org/package/strapi-hook-knex) +[![npm downloads](https://img.shields.io/npm/dm/strapi-hook-knex.svg)](https://www.npmjs.org/package/strapi-hook-knex) +[![npm dependencies](https://david-dm.org/strapi/strapi-hook-knex.svg)](https://david-dm.org/strapi/strapi-hook-knex) +[![Build status](https://travis-ci.org/strapi/strapi-hook-knex.svg?branch=master)](https://travis-ci.org/strapi/strapi-hook-knex) [![Slack status](http://strapi-slack.herokuapp.com/badge.svg)](http://slack.strapi.io) This built-in hook allows you to directly make SQL queries from your Strapi connections to your databases thanks to the [Knex node module](http://knexjs.org/). diff --git a/packages/strapi-knex/lib/index.js b/packages/strapi-hook-knex/lib/index.js similarity index 98% rename from packages/strapi-knex/lib/index.js rename to packages/strapi-hook-knex/lib/index.js index f853163ecf..ceacd92131 100755 --- a/packages/strapi-knex/lib/index.js +++ b/packages/strapi-hook-knex/lib/index.js @@ -46,7 +46,7 @@ module.exports = strapi => { initialize: cb => { // For each connection in the config register a new Knex connection. - _.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-bookshelf'}), (connection, name) => { + _.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-hook-bookshelf'}), (connection, name) => { // Make sure we use the client even if the typo is not the exact one. switch (connection.settings.client) { diff --git a/packages/strapi-knex/package.json b/packages/strapi-hook-knex/package.json similarity index 93% rename from packages/strapi-knex/package.json rename to packages/strapi-hook-knex/package.json index 4fa1428fa6..b6dc3c3df5 100755 --- a/packages/strapi-knex/package.json +++ b/packages/strapi-hook-knex/package.json @@ -1,5 +1,5 @@ { - "name": "strapi-knex", + "name": "strapi-hook-knex", "version": "3.0.0-alpha.12.7.1", "description": "Knex hook for the Strapi framework", "homepage": "http://strapi.io", @@ -19,9 +19,6 @@ "knex": "^0.13.0", "lodash": "^4.17.4" }, - "strapi": { - "isHook": true - }, "author": { "email": "hi@strapi.io", "name": "Strapi team", diff --git a/packages/strapi-mongoose/.editorconfig b/packages/strapi-hook-mongoose/.editorconfig similarity index 100% rename from packages/strapi-mongoose/.editorconfig rename to packages/strapi-hook-mongoose/.editorconfig diff --git a/packages/strapi-mongoose/.gitignore b/packages/strapi-hook-mongoose/.gitignore similarity index 100% rename from packages/strapi-mongoose/.gitignore rename to packages/strapi-hook-mongoose/.gitignore diff --git a/packages/strapi-mongoose/.npmignore b/packages/strapi-hook-mongoose/.npmignore similarity index 100% rename from packages/strapi-mongoose/.npmignore rename to packages/strapi-hook-mongoose/.npmignore diff --git a/packages/strapi-mongoose/LICENSE.md b/packages/strapi-hook-mongoose/LICENSE.md similarity index 100% rename from packages/strapi-mongoose/LICENSE.md rename to packages/strapi-hook-mongoose/LICENSE.md diff --git a/packages/strapi-mongoose/README.md b/packages/strapi-hook-mongoose/README.md similarity index 52% rename from packages/strapi-mongoose/README.md rename to packages/strapi-hook-mongoose/README.md index 49c59d8f23..5f45c405c7 100755 --- a/packages/strapi-mongoose/README.md +++ b/packages/strapi-hook-mongoose/README.md @@ -1,9 +1,9 @@ -# strapi-mongoose +# strapi-hook-mongoose -[![npm version](https://img.shields.io/npm/v/strapi-mongoose.svg)](https://www.npmjs.org/package/strapi-mongoose) -[![npm downloads](https://img.shields.io/npm/dm/strapi-mongoose.svg)](https://www.npmjs.org/package/strapi-mongoose) -[![npm dependencies](https://david-dm.org/strapi/strapi-mongoose.svg)](https://david-dm.org/strapi/strapi-mongoose) -[![Build status](https://travis-ci.org/strapi/strapi-mongoose.svg?branch=master)](https://travis-ci.org/strapi/strapi-bookshelf) +[![npm version](https://img.shields.io/npm/v/strapi-hook-mongoose.svg)](https://www.npmjs.org/package/strapi-hook-mongoose) +[![npm downloads](https://img.shields.io/npm/dm/strapi-hook-mongoose.svg)](https://www.npmjs.org/package/strapi-hook-mongoose) +[![npm dependencies](https://david-dm.org/strapi/strapi-hook-mongoose.svg)](https://david-dm.org/strapi/strapi-hook-mongoose) +[![Build status](https://travis-ci.org/strapi/strapi-hook-mongoose.svg?branch=master)](https://travis-ci.org/strapi/strapi-hook-mongoose) [![Slack status](http://strapi-slack.herokuapp.com/badge.svg)](http://slack.strapi.io) This built-in hook allows you to use the [Mongoose ORM](http://mongoosejs.com/). diff --git a/packages/strapi-mongoose/lib/index.js b/packages/strapi-hook-mongoose/lib/index.js similarity index 99% rename from packages/strapi-mongoose/lib/index.js rename to packages/strapi-hook-mongoose/lib/index.js index 3b688a5608..a0c3e5e9d4 100755 --- a/packages/strapi-mongoose/lib/index.js +++ b/packages/strapi-hook-mongoose/lib/index.js @@ -49,7 +49,7 @@ module.exports = function (strapi) { */ initialize: cb => { - _.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-mongoose'}), (connection, connectionName) => { + _.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-hook-mongoose'}), (connection, connectionName) => { const instance = new Mongoose(); const { uri, host, port, username, password, database } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose); const uriOptions = uri ? url.parse(uri, true).query : {}; diff --git a/packages/strapi-mongoose/lib/relations.js b/packages/strapi-hook-mongoose/lib/relations.js similarity index 99% rename from packages/strapi-mongoose/lib/relations.js rename to packages/strapi-hook-mongoose/lib/relations.js index 1b1de2c7b5..1fbe976cac 100644 --- a/packages/strapi-mongoose/lib/relations.js +++ b/packages/strapi-hook-mongoose/lib/relations.js @@ -174,7 +174,7 @@ module.exports = { strapi.models[_.toLower(obj.ref)].globalId; // Define the object stored in database. - // The shape is this object is defined by the strapi-mongoose connector. + // The shape is this object is defined by the strapi-hook-mongoose connector. return { ref: obj.refId, kind: globalId, diff --git a/packages/strapi-mongoose/lib/utils/connectivity.js b/packages/strapi-hook-mongoose/lib/utils/connectivity.js similarity index 100% rename from packages/strapi-mongoose/lib/utils/connectivity.js rename to packages/strapi-hook-mongoose/lib/utils/connectivity.js diff --git a/packages/strapi-mongoose/lib/utils/index.js b/packages/strapi-hook-mongoose/lib/utils/index.js similarity index 100% rename from packages/strapi-mongoose/lib/utils/index.js rename to packages/strapi-hook-mongoose/lib/utils/index.js diff --git a/packages/strapi-mongoose/package.json b/packages/strapi-hook-mongoose/package.json similarity index 93% rename from packages/strapi-mongoose/package.json rename to packages/strapi-hook-mongoose/package.json index 0becf7761b..9386fbfa8d 100755 --- a/packages/strapi-mongoose/package.json +++ b/packages/strapi-hook-mongoose/package.json @@ -1,5 +1,5 @@ { - "name": "strapi-mongoose", + "name": "strapi-hook-mongoose", "version": "3.0.0-alpha.12.7.1", "description": "Mongoose hook for the Strapi framework", "homepage": "http://strapi.io", @@ -21,9 +21,6 @@ "pluralize": "^6.0.0", "strapi-utils": "3.0.0-alpha.12.7.1" }, - "strapi": { - "isHook": true - }, "author": { "email": "hi@strapi.io", "name": "Strapi team", diff --git a/packages/strapi-redis/.editorconfig b/packages/strapi-hook-redis/.editorconfig similarity index 100% rename from packages/strapi-redis/.editorconfig rename to packages/strapi-hook-redis/.editorconfig diff --git a/packages/strapi-redis/.gitignore b/packages/strapi-hook-redis/.gitignore similarity index 100% rename from packages/strapi-redis/.gitignore rename to packages/strapi-hook-redis/.gitignore diff --git a/packages/strapi-redis/.npmignore b/packages/strapi-hook-redis/.npmignore similarity index 100% rename from packages/strapi-redis/.npmignore rename to packages/strapi-hook-redis/.npmignore diff --git a/packages/strapi-redis/LICENSE.md b/packages/strapi-hook-redis/LICENSE.md similarity index 100% rename from packages/strapi-redis/LICENSE.md rename to packages/strapi-hook-redis/LICENSE.md diff --git a/packages/strapi-redis/README.md b/packages/strapi-hook-redis/README.md similarity index 100% rename from packages/strapi-redis/README.md rename to packages/strapi-hook-redis/README.md diff --git a/packages/strapi-redis/lib/index.js b/packages/strapi-hook-redis/lib/index.js similarity index 98% rename from packages/strapi-redis/lib/index.js rename to packages/strapi-hook-redis/lib/index.js index 6b26ad51e8..c224615397 100755 --- a/packages/strapi-redis/lib/index.js +++ b/packages/strapi-hook-redis/lib/index.js @@ -38,13 +38,13 @@ module.exports = function(strapi) { initialize: cb => { if (_.isEmpty(strapi.models) || !_.pickBy(strapi.config.connections, { - connector: 'strapi-redis' + connector: 'strapi-hook-redis' })) { return cb(); } const connections = _.pickBy(strapi.config.connections, { - connector: 'strapi-redis' + connector: 'strapi-hook-redis' }); if(_.size(connections) === 0) { diff --git a/packages/strapi-redis/lib/utils/connectivity.js b/packages/strapi-hook-redis/lib/utils/connectivity.js similarity index 100% rename from packages/strapi-redis/lib/utils/connectivity.js rename to packages/strapi-hook-redis/lib/utils/connectivity.js diff --git a/packages/strapi-redis/package.json b/packages/strapi-hook-redis/package.json similarity index 93% rename from packages/strapi-redis/package.json rename to packages/strapi-hook-redis/package.json index d4058c94e3..bd0487a8ff 100755 --- a/packages/strapi-redis/package.json +++ b/packages/strapi-hook-redis/package.json @@ -1,5 +1,5 @@ { - "name": "strapi-redis", + "name": "strapi-hook-redis", "version": "3.0.0-alpha.12.7.1", "description": "Redis hook for the Strapi framework", "homepage": "http://strapi.io", @@ -20,9 +20,6 @@ "stack-trace": "0.0.10", "strapi-utils": "3.0.0-alpha.12.7.1" }, - "strapi": { - "isHook": true - }, "author": { "email": "hi@strapi.io", "name": "Strapi team", diff --git a/packages/strapi-middleware-views/package.json b/packages/strapi-middleware-views/package.json index d11be2e120..77852a7944 100755 --- a/packages/strapi-middleware-views/package.json +++ b/packages/strapi-middleware-views/package.json @@ -1,7 +1,7 @@ { "name": "strapi-middleware-views", "version": "3.0.0-alpha.12.7.1", - "description": "Views hook to enable server-side rendering for the Strapi framework", + "description": "Views middleware to enable server-side rendering for the Strapi framework", "homepage": "http://strapi.io", "keywords": [ "redis", @@ -19,9 +19,6 @@ "koa-views": "^6.1.1", "lodash": "^4.17.4" }, - "strapi": { - "isHook": true - }, "author": { "email": "hi@strapi.io", "name": "Strapi team", diff --git a/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js b/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js index ba08e31551..0e8e7ac4da 100755 --- a/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js +++ b/packages/strapi-plugin-content-type-builder/controllers/ContentTypeBuilder.js @@ -207,7 +207,7 @@ module.exports = { return ctx.badRequest(null, [{ messages: [{ id: 'Connection doesn\'t exist' }] }]); } - if (connector === 'strapi-bookshelf') { + if (connector === 'strapi-hook-bookshelf') { try { const tableExists = await strapi.connections[connection].schema.hasTable(model); diff --git a/packages/strapi-plugin-content-type-builder/services/ContentTypeBuilder.js b/packages/strapi-plugin-content-type-builder/services/ContentTypeBuilder.js index eebcc5d686..0726bf0229 100755 --- a/packages/strapi-plugin-content-type-builder/services/ContentTypeBuilder.js +++ b/packages/strapi-plugin-content-type-builder/services/ContentTypeBuilder.js @@ -117,7 +117,7 @@ module.exports = { }, generateAPI: (name, description, connection, collectionName, attributes) => { - const template = _.get(strapi.config.currentEnvironment, `database.connections.${connection}.connector`, 'strapi-mongoose').split('-')[1]; + const template = _.get(strapi.config.currentEnvironment, `database.connections.${connection}.connector`, 'strapi-hook-mongoose').split('-')[1]; return new Promise((resolve, reject) => { const scope = { diff --git a/packages/strapi-plugin-settings-manager/services/SettingsManager.js b/packages/strapi-plugin-settings-manager/services/SettingsManager.js index 530b272d3b..7e104de4e9 100755 --- a/packages/strapi-plugin-settings-manager/services/SettingsManager.js +++ b/packages/strapi-plugin-settings-manager/services/SettingsManager.js @@ -650,9 +650,9 @@ module.exports = { const redisClients = ['redis']; let connector; - if (_.indexOf(bookshelfClients, client) !== -1) connector = 'strapi-bookshelf'; - if (_.indexOf(mongooseClients, client) !== -1) connector = 'strapi-mongoose'; - if (_.indexOf(redisClients, client) !== -1) connector = 'strapi-redis'; + if (_.indexOf(bookshelfClients, client) !== -1) connector = 'strapi-hook-bookshelf'; + if (_.indexOf(mongooseClients, client) !== -1) connector = 'strapi-hook-mongoose'; + if (_.indexOf(redisClients, client) !== -1) connector = 'strapi-hook-redis'; return connector; }, @@ -911,7 +911,7 @@ module.exports = { }, cleanDependency: (env, config) => { - const availableConnectors = ['strapi-mongoose', 'strapi-bookshelf', 'strapi-redis']; + const availableConnectors = ['strapi-hook-mongoose', 'strapi-hook-bookshelf', 'strapi-hook-redis']; let usedConnectors = []; const errors = []; diff --git a/packages/strapi-utils/lib/knex.js b/packages/strapi-utils/lib/knex.js index 03b4c8affa..66d4621aa2 100755 --- a/packages/strapi-utils/lib/knex.js +++ b/packages/strapi-utils/lib/knex.js @@ -21,10 +21,10 @@ module.exports = scope => { // First, make sure the application we have access to // the migration generator. try { - require.resolve(path.resolve(scope.rootPath, 'node_modules', 'strapi-knex')); + require.resolve(path.resolve(scope.rootPath, 'node_modules', 'strapi-hook-knex')); } catch (err) { console.error('Impossible to call the Knex migration tool.'); - console.error('You can install it with `$ npm install strapi-knex --save`.'); + console.error('You can install it with `$ npm install strapi-hook-knex --save`.'); process.exit(1); } diff --git a/packages/strapi/lib/core/configurations.js b/packages/strapi/lib/core/configurations.js index ae39c6b89c..ceabc5fae6 100755 --- a/packages/strapi/lib/core/configurations.js +++ b/packages/strapi/lib/core/configurations.js @@ -281,7 +281,7 @@ module.exports.app = async function() { // Enable hooks and dependencies related to the connections. for (let name in this.config.connections) { const connection = this.config.connections[name]; - const connector = connection.connector.replace('strapi-', ''); + const connector = connection.connector.replace('strapi-hook-', ''); enableHookNestedDependencies.call(this, connector, flattenHooksConfig); } @@ -333,7 +333,7 @@ module.exports.app = async function() { const enableHookNestedDependencies = function (name, flattenHooksConfig, force = false) { if (!this.hook[name]) { - this.log.warn(`(hook:${name}) \`strapi-${name}\` is missing in your dependencies. Please run \`npm install strapi-${name}\``); + this.log.warn(`(hook:${name}) \`strapi-hook-${name}\` is missing in your dependencies. Please run \`npm install strapi-hook-${name}\``); } // Couldn't find configurations for this hook. @@ -347,7 +347,7 @@ const enableHookNestedDependencies = function (name, flattenHooksConfig, force = const connector = get(this.config.connections, models[model].connection, {}).connector; if (connector) { - return connector.replace('strapi-', '') === name; + return connector.replace('strapi-hook-', '') === name; } return false; @@ -363,7 +363,7 @@ const enableHookNestedDependencies = function (name, flattenHooksConfig, force = // Enabled dependencies. if (get(this.hook, `${name}.dependencies`, []).length > 0) { this.hook[name].dependencies.forEach(dependency => { - enableHookNestedDependencies.call(this, dependency.replace('strapi-', ''), flattenHooksConfig, true); + enableHookNestedDependencies.call(this, dependency.replace('strapi-hook-', ''), flattenHooksConfig, true); }); } } diff --git a/packages/strapi/lib/core/hooks.js b/packages/strapi/lib/core/hooks.js index e03c210761..834da78848 100755 --- a/packages/strapi/lib/core/hooks.js +++ b/packages/strapi/lib/core/hooks.js @@ -15,18 +15,7 @@ module.exports = function() { const cwd = ''; // Load configurations. - glob('./node_modules/strapi-*', { - ignore: [ - './node_modules/strapi-admin', - './node_modules/strapi-utils', - './node_modules/strapi-generate*', - './node_modules/strapi-plugin-*', - './node_modules/strapi-helper-*', - './node_modules/strapi-middleware-*', - './node_modules/strapi-upload-*', - './node_modules/strapi-email-*', - './node_modules/strapi-lint' - ], + glob('./node_modules/strapi-hook-*', { cwd: this.config.appPath }, (err, files) => { if (err) { @@ -71,17 +60,9 @@ const mountHooks = function (files, cwd, isPlugin) { return (resolve, reject) => parallel( files.map(p => cb => { - const extractStr = p - .split('/') - .pop() - .replace(/^strapi(-|\.)/, '') - .split('-'); - - const name = lowerFirst( - extractStr.length === 1 - ? extractStr[0] - : extractStr.map(p => upperFirst(p)).join('') - ); + const folders = p.replace(/^.\/node_modules\/strapi-hook-/, './') + .split('/'); + const name = isPlugin ? folders[folders.length - 2] : folders[1]; fs.readFile(path.resolve(this.config.appPath, cwd, p, 'package.json'), (err, content) => { try { diff --git a/packages/strapi/lib/hooks/index.js b/packages/strapi/lib/hooks/index.js index ae3d3e1a81..c7e2cb11cf 100755 --- a/packages/strapi/lib/hooks/index.js +++ b/packages/strapi/lib/hooks/index.js @@ -83,7 +83,7 @@ module.exports = async function() { } // Initialize array. - let previousDependencies = this.hook[hook].dependencies.map(x => x.replace('strapi-', '')) || []; + let previousDependencies = this.hook[hook].dependencies.map(x => x.replace('strapi-hook', '')) || []; // Add BEFORE middlewares to load and remove the current one // to avoid that it waits itself. diff --git a/scripts/setup.js b/scripts/setup.js index 908a20391d..3d58c6d9c4 100755 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -99,17 +99,17 @@ shell.cd('../strapi-generate-new'); watcher('', 'npm install ../strapi-utils'); watcher('📦 Linking strapi-generate-new', 'npm link'); -shell.cd('../strapi-mongoose'); +shell.cd('../strapi-hook-mongoose'); watcher('', 'npm install ../strapi-utils'); -watcher('📦 Linking strapi-mongoose...', 'npm link'); +watcher('📦 Linking strapi-hook-mongoose...', 'npm link'); -shell.cd('../strapi-knex'); -watcher('📦 Linking strapi-knex...', 'npm link'); +shell.cd('../strapi-hook-knex'); +watcher('📦 Linking strapi-hook-knex...', 'npm link'); -shell.cd('../strapi-bookshelf'); +shell.cd('../strapi-hook-bookshelf'); watcher('', 'npm install ../strapi-utils'); -watcher('', 'npm install ../strapi-knex'); -watcher('📦 Linking strapi-bookshelf...', 'npm link'); +watcher('', 'npm install ../strapi-hook-knex'); +watcher('📦 Linking strapi-hook-bookshelf...', 'npm link'); shell.cd('../strapi'); watcher('', 'npm install ../strapi-generate ../strapi-generate-admin ../strapi-generate-api ../strapi-generate-new ../strapi-generate-plugin ../strapi-generate-policy ../strapi-generate-service ../strapi-utils');