Skip to content
Permalink
Browse files

Setup DB

  • Loading branch information...
davidhellmann committed Mar 21, 2019
1 parent 30330f7 commit 0bc4c332a0926204925ffef1380a85742c78d644
@@ -48,8 +48,8 @@ describe('it downloads craft & moves file', () => {

it('adds environment file', () => {
assert.file([
'___dist/.env.php',
'___dist/example.env.php',
'___dist/.env',
'___dist/.env.example',
'___dist/config/general.php'
])
})
@@ -95,15 +95,15 @@ module.exports = {
projectContext: [
'craftCMS3'
],
src: '___src/_craftCMS3/.env.php',
dest: '___dist/.env.php'
src: '___src/_craftCMS3/.env',
dest: '___dist/.env'
},
{
projectContext: [
'craftCMS3'
],
src: '___src/_craftCMS3/example.env.php',
dest: '___dist/example.env.php'
src: '___src/_craftCMS3/.env.example',
dest: '___dist/.env.example'
},
{
projectContext: [
@@ -11,6 +11,10 @@ module.exports = {
{
src: '___src/scripts/FauxTwigExtension.php',
dest: 'scripts/FauxTwigExtension.php'
},
{
src: '___src/scripts/setup-db.sh',
dest: 'scripts/setup-db.sh'
}
]
}
@@ -130,6 +130,10 @@ module.exports = class extends Generator {
// Package JSON
this.writePackageJSON().writing(this)

if (this.props.craftCMS3Install) {
this.spawnCommandSync('cd', ['___dist', '&&', 'rm .env', '&&', 'rm .env.example'])
}

// Craft CMS 3
if (this.props.projectType === 'craftCMS3') {
this.logMessage({message: 'Moving Craft Folders'});
@@ -180,7 +184,8 @@ module.exports = class extends Generator {
if (file.projectContext.includes(this.props.projectType)) {
this.fs.copy(
this.templatePath(file.src),
this.destinationPath(file.dest)
this.destinationPath(file.dest),
{ overwrite: true }
)
}
})
@@ -235,6 +240,14 @@ module.exports = class extends Generator {
`It was an honor to me to setup this project with you ${chalk.red('<3')}!`
))


this.logMessage({message: 'Setup Database'})
if (this.commands.yarn) {
this.spawnCommandSync('yarn', ['setup:db'])
} else {
this.spawnCommandSync('npm', ['run'], ['setup:db'])
}

this.logMessage({message: 'Init Project', short: false})

if (process.env.NODE_ENV === 'test') {
@@ -245,5 +258,12 @@ module.exports = class extends Generator {
} else {
this.spawnCommandSync('npm', ['run'], ['start'])
}

this.logMessage({message: 'Setup Database'})
if (this.commands.yarn) {
this.spawnCommandSync('yarn', ['setup:db'])
} else {
this.spawnCommandSync('npm', ['run'], ['setup:db'])
}
}
}
@@ -37,7 +37,8 @@ function addNPMScripts(files = {}, context) {
'backup:assets': './___dist/craft-scripts/backup_assets.sh',
'backup:all': 'npm run backup:db && npm run backup:assets',
'clear:caches': './___dist/craft-scripts/clear_caches.sh',
'install:plugins': 'cd ___dist && sh ./plugins.sh'
'install:plugins': 'cd ___dist && sh ./plugins.sh',
'setup:db': 'cd scripts && sh ./setup-db.sh'
}
})
}
@@ -12,7 +12,79 @@ const promptsCraftCMS3 = [
description: 'Do you want to install the Craft 3 version via Composer?'
}),
default: true
}
},
{
type: 'input',
name: 'dbDriver',
message: message({
headline: 'Database driver',
description: 'mysql or pgsql'
}),
default: 'mysql'
},
{
type: 'input',
name: 'dbHost',
message: message({
headline: 'Database host',
description: 'localhost or IP'
}),
default: 'localhost'
},
{
type: 'input',
name: 'dbUser',
message: message({
headline: 'Database user',
description: 'Your database user'
}),
default: 'root'
},
{
type: 'input',
name: 'dbPassword',
message: message({
headline: 'Database password',
description: 'Your database password'
}),
default: 'root'
},
{
type: 'input',
name: 'dbName',
message: message({
headline: 'Database name',
description: 'Your database name'
}),
default: 'baukasten_database'
},
{
type: 'input',
name: 'dbTablePrefix',
message: message({
headline: 'Database table prefix',
description: 'Your database table prefix'
}),
default: ''
},
{
type: 'input',
name: 'dbPort',
message: message({
headline: 'Database port',
description: 'Your database port'
}),
default: '3306'
},
{
type: 'confirm',
name: 'importDB',
message: message({
headline: 'Import Baukasten Database (recommended)',
description: 'Do you like to import the Baukasten Datebase?'
}),
default: true
},
]

module.exports = promptsCraftCMS3
@@ -0,0 +1,32 @@
# The environment Craft is currently running in ('dev', 'staging', 'production', etc.)
ENVIRONMENT="local"

# The secure key Craft will use for hashing and encrypting data
SECURITY_KEY=""

# The database driver that will be used ('mysql' or 'pgsql')
DB_DRIVER="<%= dbDriver %>"

# The database server name or IP address (usually this is 'localhost' or '127.0.0.1')
DB_SERVER="<%= dbHost %>"

# The database username to connect with
DB_USER="<%= dbUser %>"

# The database password to connect with
DB_PASSWORD="<%= dbPassword %>"

# The name of the database to select
DB_DATABASE="<%= dbName %>"

# The database schema that will be used (PostgreSQL only)
DB_SCHEMA="public"

# The prefix that should be added to generated table names (only necessary if multiple things are sharing the same database)
DB_TABLE_PREFIX="<%= dbTablePrefix %>"

# The port to connect to the database with. Will default to 5432 for PostgreSQL and 3306 for MySQL.
DB_PORT="<%= dbPort %>"

# Root Url
SITE_URL="<%= projectProxy %>/"
@@ -0,0 +1,32 @@
# The environment Craft is currently running in ('dev', 'staging', 'production', etc.)
ENVIRONMENT="local"

# The secure key Craft will use for hashing and encrypting data
SECURITY_KEY=""

# The database driver that will be used ('mysql' or 'pgsql')
DB_DRIVER="___DB_DRIVER___"

# The database server name or IP address (usually this is 'localhost' or '127.0.0.1')
DB_SERVER="___DB_HOST___"

# The database username to connect with
DB_USER="___DB_USER___"

# The database password to connect with
DB_PASSWORD="___DB_PASSWORD___"

# The name of the database to select
DB_DATABASE="___DB_NAME___"

# The database schema that will be used (PostgreSQL only)
DB_SCHEMA="public"

# The prefix that should be added to generated table names (only necessary if multiple things are sharing the same database)
DB_TABLE_PREFIX="___DB_PREFIX___"

# The port to connect to the database with. Will default to 5432 for PostgreSQL and 3306 for MySQL.
DB_PORT="___DB_PORT___"

# Root Url
SITE_URL="___SITE_URL___"

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 0bc4c33

Please sign in to comment.
You can’t perform that action at this time.