-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#20] include project config, Mailpit setup #22
Changes from all commits
17378fb
7ba2dbe
ab46c36
d75b551
c7bc861
0290c0d
a62e992
db59feb
81d715f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,14 @@ CRAFT_APP_ID= | |
# The environment Craft is currently running in (dev, staging, production, etc.) | ||
CRAFT_ENVIRONMENT=dev | ||
|
||
[email protected] | ||
SYSTEM_EMAIL_SENDER="Craft CMS" | ||
SYSTEM_EMAIL_HOSTNAME= | ||
SYSTEM_EMAIL_PORT= | ||
SYSTEM_EMAIL_USERNAME= | ||
SYSTEM_EMAIL_PASSWORD= | ||
|
||
# Database connection settings | ||
CRAFT_DB_DRIVER=mysql | ||
CRAFT_DB_SERVER=127.0.0.1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,13 @@ CRAFT_APP_ID= | |
# The environment Craft is currently running in (dev, staging, production, etc.) | ||
CRAFT_ENVIRONMENT=production | ||
|
||
[email protected] | ||
SYSTEM_EMAIL_HOSTNAME= | ||
SYSTEM_EMAIL_PORT= | ||
SYSTEM_EMAIL_USERNAME= | ||
SYSTEM_EMAIL_PASSWORD= | ||
|
||
# Database connection settings | ||
CRAFT_DB_DRIVER=mysql | ||
CRAFT_DB_SERVER=127.0.0.1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,13 @@ CRAFT_APP_ID= | |
# The environment Craft is currently running in (dev, staging, production, etc.) | ||
CRAFT_ENVIRONMENT=staging | ||
|
||
[email protected] | ||
SYSTEM_EMAIL_HOSTNAME= | ||
SYSTEM_EMAIL_PORT= | ||
SYSTEM_EMAIL_USERNAME= | ||
SYSTEM_EMAIL_PASSWORD= | ||
|
||
# Database connection settings | ||
CRAFT_DB_DRIVER=mysql | ||
CRAFT_DB_SERVER=127.0.0.1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,7 @@ node_modules | |
/web/dist | ||
/.vite | ||
php-cs-fixer.cache | ||
|
||
# BEGIN-STARTER-ONLY | ||
config/license.key | ||
# END-STARTER-ONLY | ||
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is relatively simple to Regex replace everything within the tags |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
class ScriptHelpers | ||
{ | ||
public static function replaceFileText(string $filePath, string $pattern, string $replacement): void | ||
{ | ||
$fileContent = file_get_contents($filePath); | ||
$fileContent = preg_replace($pattern, $replacement, $fileContent); | ||
file_put_contents($filePath, $fileContent); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
use craft\helpers\Console; | ||
use craft\helpers\StringHelper; | ||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realized I could use these Craft helpers, which makes |
||
|
||
require_once 'ScriptHelpers.php'; | ||
require_once 'vendor/autoload.php'; | ||
|
||
$cwd = getcwd(); | ||
|
||
/** | ||
* Prompt the user for input | ||
*/ | ||
$projectName = Console::prompt('What is the name of your project (Example: My Client Name)? ', [ | ||
'required' => true, | ||
]); | ||
|
||
Console::output("Great! We'll use the name: $projectName"); | ||
|
||
$suggestedProjectSlug = StringHelper::toKebabCase($projectName); | ||
|
||
$projectSlugPrompt = Console::prompt("Customize the project slug? This controls the DDEV URL, etc.", [ | ||
'default' => $suggestedProjectSlug, | ||
]); | ||
|
||
$projectSlug = !empty(trim($projectSlugPrompt)) ? StringHelper::toKebabCase($projectSlugPrompt) : $suggestedProjectSlug; | ||
|
||
Console::output("Great! We'll use $projectSlug"); | ||
|
||
/** | ||
* Update DDEV config | ||
*/ | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/.ddev/config.yaml", | ||
pattern: "/name:\s+viget-craft-starter/", | ||
replacement: "name: $projectSlug", | ||
); | ||
|
||
/** | ||
* Update package.json | ||
*/ | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/package.json", | ||
pattern: "/\"name\": \"viget-craft-starter\"/", | ||
replacement: "\"name\": \"$projectSlug\"", | ||
); | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/package-lock.json", | ||
pattern: "/\"name\": \"viget-craft-starter\"/", | ||
replacement: "\"name\": \"$projectSlug\"", | ||
); | ||
|
||
/** | ||
* Update project config | ||
*/ | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/config/project/project.yaml", | ||
pattern: "/Viget Craft Starter/", | ||
replacement: "$projectName", | ||
); | ||
|
||
// Replace plugin license keys. | ||
// These are regenerated when viewing the Control Panel | ||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/config/project/project.yaml", | ||
pattern: "/ licenseKey: REPLACE[\r\n|\r|\n]/", // Make sure to remove new line too | ||
replacement: "", | ||
); | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/config/project/siteGroups/805d8826-faed-4186-9b88-f509eb9b07e6.yaml", | ||
pattern: "/Viget Craft Starter/", | ||
replacement: "$projectName", | ||
); | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/config/project/sites/default--35b563a0-4662-40b9-b885-a8450a2868d9.yaml", | ||
pattern: "/Viget Craft Starter/", | ||
replacement: "$projectName", | ||
); | ||
|
||
/** | ||
* .gitignore | ||
*/ | ||
|
||
ScriptHelpers::replaceFileText( | ||
filePath: "$cwd/.gitignore", | ||
pattern: "/# BEGIN-STARTER-ONLY\X*# END-STARTER-ONLY/m", | ||
replacement: '', | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
headingLevels: | ||
- 1 | ||
- 2 | ||
- 3 | ||
- 4 | ||
- 5 | ||
- 6 | ||
name: Simple | ||
toolbar: | ||
- heading | ||
- '|' | ||
- bold | ||
- italic | ||
- link |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
dateModified: 1716932096 | ||
email: | ||
fromEmail: $SYSTEM_EMAIL_FROM | ||
fromName: 'Viget Craft Starter' | ||
replyToEmail: null | ||
template: null | ||
transportSettings: | ||
host: $SYSTEM_EMAIL_HOSTNAME | ||
password: $SYSTEM_EMAIL_PASSWORD | ||
port: $SYSTEM_EMAIL_PORT | ||
useAuthentication: '1' | ||
username: $SYSTEM_EMAIL_USERNAME | ||
transportType: craft\mail\transportadapters\Smtp | ||
Comment on lines
+3
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes we'll use some kind of SMTP service on our projects. I've found it to be necessary to get password reset emails to work, even for small clients. It's super affordable: https://aws.amazon.com/ses/pricing/ |
||
meta: | ||
__names__: | ||
35b563a0-4662-40b9-b885-a8450a2868d9: 'Viget Craft Starter' # Viget Craft Starter | ||
805d8826-faed-4186-9b88-f509eb9b07e6: 'Viget Craft Starter' # Viget Craft Starter | ||
b7e66782-af96-4012-9e17-914134073ced: Simple # Simple | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a little funny that these UUIDs will be repeated across projects... but it would be impossible for two Craft projects to be installed using the exact same DB tables, so it's not really an issue. |
||
plugins: | ||
aws-s3: | ||
edition: standard | ||
enabled: true | ||
schemaVersion: '2.0' | ||
ckeditor: | ||
edition: standard | ||
enabled: true | ||
schemaVersion: 3.0.0.0 | ||
classnames: | ||
edition: standard | ||
enabled: true | ||
schemaVersion: 3.0.0 | ||
cp-field-inspect: | ||
edition: standard | ||
enabled: true | ||
schemaVersion: 1.0.0 | ||
empty-coalesce: | ||
edition: standard | ||
enabled: true | ||
schemaVersion: 1.0.0 | ||
imager-x: | ||
edition: lite | ||
enabled: true | ||
licenseKey: REPLACE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We remove these licenseKey lines. They auto-regenerate with new numbers when you create a new project and visit the Craft admin for the first time. |
||
schemaVersion: 4.0.0 | ||
navigation: | ||
edition: standard | ||
enabled: true | ||
licenseKey: REPLACE | ||
schemaVersion: 2.1.0 | ||
retour: | ||
edition: standard | ||
enabled: true | ||
licenseKey: REPLACE | ||
schemaVersion: 3.0.12 | ||
seomatic: | ||
edition: standard | ||
enabled: true | ||
licenseKey: REPLACE | ||
schemaVersion: 3.0.12 | ||
vite: | ||
edition: standard | ||
enabled: true | ||
schemaVersion: 1.0.0 | ||
system: | ||
edition: solo | ||
live: true | ||
name: 'Viget Craft Starter' | ||
schemaVersion: 5.0.0.20 | ||
timeZone: America/Los_Angeles | ||
users: | ||
allowPublicRegistration: false | ||
defaultGroup: null | ||
photoSubpath: null | ||
photoVolumeUid: null | ||
require2fa: false | ||
requireEmailVerification: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name: 'Viget Craft Starter' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
baseUrl: $PRIMARY_SITE_URL | ||
enabled: true | ||
handle: default | ||
hasUrls: true | ||
language: en-US | ||
name: 'Viget Craft Starter' | ||
primary: true | ||
siteGroup: 805d8826-faed-4186-9b88-f509eb9b07e6 # Viget Craft Starter | ||
sortOrder: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard coding these values into the DDEV config makes it harder to accidentally override these with production credentials.