mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 07:38:41 +00:00
Install db dependencies on app creation
This commit is contained in:
parent
a892a6943d
commit
23ee0b25bf
@ -40,7 +40,8 @@ module.exports = scope => {
|
|||||||
'dependencies': {
|
'dependencies': {
|
||||||
'lodash': '4.x.x',
|
'lodash': '4.x.x',
|
||||||
'strapi': getDependencyVersion(cliPkg, 'strapi'),
|
'strapi': getDependencyVersion(cliPkg, 'strapi'),
|
||||||
'strapi-mongoose': getDependencyVersion(cliPkg, 'strapi')
|
[scope.client.connector]: getDependencyVersion(cliPkg, 'strapi'),
|
||||||
|
[scope.client.module]: scope.client.version
|
||||||
},
|
},
|
||||||
'author': {
|
'author': {
|
||||||
'name': scope.author || 'A Strapi developer',
|
'name': scope.author || 'A Strapi developer',
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
// Node.js core.
|
// Node.js core.
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const exec = require('child_process').exec;
|
||||||
|
const execSync = require('child_process').execSync;
|
||||||
|
|
||||||
// Public node modules.
|
// Public node modules.
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@ -47,6 +49,7 @@ module.exports = (scope, cb) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.info('Let\s configurate the connection to your database:');
|
logger.info('Let\s configurate the connection to your database:');
|
||||||
|
let formSteps = new Promise(resolve => {
|
||||||
inquirer
|
inquirer
|
||||||
.prompt([
|
.prompt([
|
||||||
{
|
{
|
||||||
@ -66,32 +69,55 @@ module.exports = (scope, cb) => {
|
|||||||
name: 'Postgres',
|
name: 'Postgres',
|
||||||
value: {
|
value: {
|
||||||
database: 'postgres',
|
database: 'postgres',
|
||||||
connector: 'strapi-bookshelf'
|
connector: 'strapi-bookshelf',
|
||||||
|
module: 'pg'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'MySQL',
|
name: 'MySQL',
|
||||||
value: {
|
value: {
|
||||||
database: 'mysql',
|
database: 'mysql',
|
||||||
connector: 'strapi-bookshelf'
|
connector: 'strapi-bookshelf',
|
||||||
|
module: 'mysql'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Sqlite3',
|
name: 'Sqlite3',
|
||||||
value: {
|
value: {
|
||||||
database: 'sqlite3',
|
database: 'sqlite3',
|
||||||
connector: 'strapi-bookshelf'
|
connector: 'strapi-bookshelf',
|
||||||
|
module: 'sqlite3'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Redis',
|
name: 'Redis',
|
||||||
value: {
|
value: {
|
||||||
database: 'redis',
|
database: 'redis',
|
||||||
connector: 'strapi-bookshelf'
|
connector: 'strapi-redis'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
])
|
||||||
|
.then(answers => {
|
||||||
|
scope.client = answers.client;
|
||||||
|
scope.database = {
|
||||||
|
connector: answers.client.connector,
|
||||||
|
settings: {
|
||||||
|
client: answers.client.database
|
||||||
},
|
},
|
||||||
|
options: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
formSteps = formSteps.then(() => {
|
||||||
|
const asyncFn = [
|
||||||
|
new Promise(resolve => {
|
||||||
|
inquirer
|
||||||
|
.prompt([
|
||||||
{
|
{
|
||||||
type: 'input',
|
type: 'input',
|
||||||
prefix: '',
|
prefix: '',
|
||||||
@ -120,7 +146,7 @@ module.exports = (scope, cb) => {
|
|||||||
redis: 6379
|
redis: 6379
|
||||||
};
|
};
|
||||||
|
|
||||||
return ports[answers.client.database];
|
return ports[scope.client.database];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -137,22 +163,40 @@ module.exports = (scope, cb) => {
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
.then(answers => {
|
.then(answers => {
|
||||||
scope.database = {
|
scope.database.host = answers.host;
|
||||||
connector: answers.client.connector,
|
scope.database.port = answers.port;
|
||||||
settings: {
|
scope.database.database = answers.name;
|
||||||
client: answers.client.database,
|
scope.database.username = answers.username;
|
||||||
host: answers.host,
|
scope.database.password = answers.password;
|
||||||
port: answers.port,
|
|
||||||
database: answers.name,
|
resolve();
|
||||||
username: answers.username,
|
});
|
||||||
password: answers.password
|
}),
|
||||||
},
|
new Promise(resolve => {
|
||||||
options: {}
|
let cmd = `npm install --prefix ${scope.rootPath}_ ${scope.client.connector}@alpha`;
|
||||||
};
|
if (scope.client.module) {
|
||||||
|
cmd += ` ${scope.client.module}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
exec(cmd, () => {
|
||||||
|
if (scope.client.module) {
|
||||||
|
const lock = require(`${scope.rootPath}_/package-lock.json`);
|
||||||
|
scope.client.version = lock.dependencies[scope.client.module].version;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
Promise.all(asyncFn)
|
||||||
|
.then(() => {
|
||||||
|
execSync(`rm -r ${scope.rootPath}_`);
|
||||||
|
|
||||||
logger.info('Copying the dashboard...');
|
logger.info('Copying the dashboard...');
|
||||||
|
|
||||||
// Trigger callback with no error to proceed.
|
// Trigger callback with no error to proceed.
|
||||||
return cb.success();
|
cb.success();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user