Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Oct 19, 2017
0 parents commit e8f5dfc
Show file tree
Hide file tree
Showing 90 changed files with 16,813 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "> 5% in BE"],
"uglify": true
},
"modules": false
}]
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread"
],
"env": {
"test": {
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
]
}
}
}
5 changes: 5 additions & 0 deletions .browserlistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Browsers we support via Babel, Autoprefixer etc.
# https://github.com/ai/browserslist

last 2 versions
> 5% in BE
35 changes: 35 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://spoon.dev

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=spoon
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=preview
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

BUGSNAG_API_KEY=
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "spatie"
}
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/node_modules
/public/css
/public/js
/public/hot
/public/mix-manifest.json
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
22 changes: 22 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage/*')
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->name('_ide_helper')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);


return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"7.1.6","version":"2.4.0:v2.4.0#63661f3add3609e90e4ab8115113e189ae547bb4","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"ensure_fully_multiline":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sortAlgorithm":"alpha"},"no_unused_imports":true},"hashes":{"\/app\/Console\/Kernel.php":21628180,"\/app\/Exceptions\/Handler.php":2891092887,"\/app\/helpers.php":1369773591,"\/app\/Http\/Controllers\/Auth\/ForgotPasswordController.php":190077705,"\/app\/Http\/Controllers\/Auth\/LoginController.php":2239826440,"\/app\/Http\/Controllers\/Auth\/RegisterController.php":342995454,"\/app\/Http\/Controllers\/Auth\/ResetPasswordController.php":2034098647,"\/app\/Http\/Controllers\/Controller.php":2377246532,"\/app\/Http\/Kernel.php":2964118865,"\/app\/Http\/Middleware\/EncryptCookies.php":2788471620,"\/app\/Http\/Middleware\/RedirectIfAuthenticated.php":3257299207,"\/app\/Http\/Middleware\/TrimStrings.php":2271586827,"\/app\/Http\/Middleware\/VerifyCsrfToken.php":1431329565,"\/app\/Models\/User.php":1812896055,"\/app\/Providers\/AppServiceProvider.php":3195458341,"\/app\/Providers\/AuthServiceProvider.php":1092299230,"\/app\/Providers\/BroadcastServiceProvider.php":3839728412,"\/app\/Providers\/EventServiceProvider.php":1058015242,"\/app\/Providers\/RouteServiceProvider.php":1290056425,"\/bootstrap\/app.php":1859188755,"\/bootstrap\/autoload.php":4265890474,"\/config\/app.php":1412724278,"\/config\/auth.php":3438971357,"\/config\/broadcasting.php":2102194954,"\/config\/cache.php":3942771411,"\/config\/database.php":1568079795,"\/config\/filesystems.php":1119715000,"\/config\/laravel-backup.php":4082537142,"\/config\/mail.php":24057255,"\/config\/queue.php":3716343259,"\/config\/services.php":1160113540,"\/config\/session.php":2381182299,"\/config\/view.php":3333587402,"\/database\/factories\/ModelFactory.php":2058315255,"\/database\/migrations\/2014_10_12_000000_create_users_table.php":2516204209,"\/database\/migrations\/2014_10_12_100000_create_password_resets_table.php":2423716589,"\/database\/seeds\/DatabaseSeeder.php":2272122295,"\/Envoy.blade.php":3385390974,"\/public\/index.php":40188297,"\/resources\/lang\/en\/auth.php":3307291722,"\/resources\/lang\/en\/pagination.php":2109704695,"\/resources\/lang\/en\/passwords.php":3291800654,"\/resources\/lang\/en\/validation.php":2098982946,"\/resources\/views\/welcome.blade.php":3979618423,"\/routes\/api.php":148640589,"\/routes\/channels.php":627188882,"\/routes\/console.php":2045403946,"\/routes\/web.php":2811554343,"\/server.php":2108507027,"\/tests\/CreatesApplication.php":1811814938,"\/tests\/Feature\/ExampleTest.php":3880437853,"\/tests\/TestCase.php":1353191102,"\/tests\/Unit\/ExampleTest.php":4124306424}}
3 changes: 3 additions & 0 deletions .psysh.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

\Spatie\TinkerTools\ShortClassNames::register();
9 changes: 9 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "stylelint-config-standard",
"ignoreFiles": "resources/assets/css/**/vendor/*.css",
"rules": {
"indentation": [4],
"number-leading-zero": null,
"selector-pseudo-element-colon-notation": "single"
}
}
154 changes: 154 additions & 0 deletions Envoy.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
@setup
require __DIR__.'/vendor/autoload.php';
(new \Dotenv\Dotenv(__DIR__, '.env'))->load();

$server = "";
$userAndServer = 'forge@'. $server;
$repository = "spatie/{$server}";
$baseDir = "/home/forge/{$server}";
$releasesDir = "{$baseDir}/releases";
$currentDir = "{$baseDir}/current";
$newReleaseName = date('Ymd-His');
$newReleaseDir = "{$releasesDir}/{$newReleaseName}";
$user = get_current_user();

function logMessage($message) {
return "echo '\033[32m" .$message. "\033[0m';\n";
}
@endsetup

@servers(['local' => '127.0.0.1', 'remote' => $userAndServer])

@macro('deploy')
startDeployment
cloneRepository
runComposer
runYarn
generateAssets
updateSymlinks
optimizeInstallation
backupDatabase
migrateDatabase
blessNewRelease
cleanOldReleases
finishDeploy
@endmacro

@macro('deploy-code')
deployOnlyCode
@endmacro

@task('startDeployment', ['on' => 'local'])
{{ logMessage("🏃 Starting deployment...") }}
git checkout master
git pull origin master
@endtask

@task('cloneRepository', ['on' => 'remote'])
{{ logMessage("🌀 Cloning repository...") }}
[ -d {{ $releasesDir }} ] || mkdir {{ $releasesDir }};
cd {{ $releasesDir }};

# Create the release dir
mkdir {{ $newReleaseDir }};

# Clone the repo
git clone --depth 1 git@github.com:{{ $repository }} {{ $newReleaseName }}

# Configure sparse checkout
cd {{ $newReleaseDir }}
git config core.sparsecheckout true
echo "*" > .git/info/sparse-checkout
echo "!storage" >> .git/info/sparse-checkout
echo "!public/build" >> .git/info/sparse-checkout
git read-tree -mu HEAD

# Mark release
cd {{ $newReleaseDir }}
echo "{{ $newReleaseName }}" > public/release-name.txt
@endtask

@task('runComposer', ['on' => 'remote'])
{{ logMessage("🚚 Running Composer...") }}
cd {{ $newReleaseDir }};
composer install --prefer-dist --no-scripts --no-dev -q -o;
@endtask

@task('runYarn', ['on' => 'remote'])
{{ logMessage("📦 Running Yarn...") }}
cd {{ $newReleaseDir }};
yarn config set ignore-engines true
yarn
@endtask

@task('generateAssets', ['on' => 'remote'])
{{ logMessage("🌅 Generating assets...") }}
cd {{ $newReleaseDir }};
yarn run production -- --progress false
@endtask

@task('updateSymlinks', ['on' => 'remote'])
{{ logMessage("🔗 Updating symlinks to persistent data...") }}
# Remove the storage directory and replace with persistent data
rm -rf {{ $newReleaseDir }}/storage;
cd {{ $newReleaseDir }};
ln -nfs {{ $baseDir }}/persistent/storage storage;

# Import the environment config
cd {{ $newReleaseDir }};
ln -nfs {{ $baseDir }}/.env .env;
@endtask

@task('optimizeInstallation', ['on' => 'remote'])
{{ logMessage("✨ Optimizing installation...") }}
cd {{ $newReleaseDir }};
php artisan clear-compiled;
php artisan optimize;
@endtask

@task('backupDatabase', ['on' => 'remote'])
{{ logMessage("📀 Backing up database...") }}
cd {{ $newReleaseDir }}
php artisan backup:run
@endtask

@task('migrateDatabase', ['on' => 'remote'])
{{ logMessage("🙈 Migrating database...") }}
cd {{ $newReleaseDir }};
php artisan migrate --force;
@endtask

@task('blessNewRelease', ['on' => 'remote'])
{{ logMessage("🙏 Blessing new release...") }}
ln -nfs {{ $newReleaseDir }} {{ $currentDir }};
cd {{ $newReleaseDir }}
php artisan config:clear
php artisan cache:clear
php artisan config:cache

sudo service php7.1-fpm restart
sudo supervisorctl restart all
@endtask

@task('cleanOldReleases', ['on' => 'remote'])
{{ logMessage("🚾 Cleaning up old releases...") }}
# Delete all but the 5 most recent.
cd {{ $releasesDir }}
ls -dt {{ $releasesDir }}/* | tail -n +6 | xargs -d "\n" sudo chown -R forge .;
ls -dt {{ $releasesDir }}/* | tail -n +6 | xargs -d "\n" rm -rf;
@endtask

@task('finishDeploy', ['on' => 'local'])
{{ logMessage("🚀 Application deployed!") }}
@endtask

@task('deployOnlyCode',['on' => 'remote'])
{{ logMessage("💻 Deploying code changes...") }}
cd {{ $currentDir }}
git pull origin master
php artisan config:clear
php artisan cache:clear
php artisan config:cache
sudo supervisorctl restart all
sudo service php7.1-fpm restart
@endtask
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Spoon

Spoon is the Laravel template that is used for our projects that don't use [Blender](https://github.com/spatie/blender), which ships with big features like i18n and an admin panel. Spoon is relatively unopinionated, and comes with some utility packages we use in every project.

You may use our template but please notice that we offer no support whatsoever. We also don't
follow semver for this project and won't guarantee that the code (especially the master branch) is stable. In short: when using this, you're on your own.

## What's in the Box?

Some highlights of what's included here:

- Devtools: debugbar, laravel-mail-preview, laravel-tail, laravel-tinker-tools
- Database backups
- Bugsnag integration
- PHP-CS fixer
- A zero-downtime deploy script with Envoy
- Our babel setup
- CSS transpilation with CSSNext

## Install

This guide assumes you're using [Laravel Valet](https://github.com/laravel/valet)

### Laravel App

Download the master branch

```bash
git clone https://github.com/spatie/spoon.git
```

Install the composer dependencies

```bash
composer install
```

Make a copy of the `.env.example` file

```bash
cp .env.example .env
```

Generate an application key

```bash
php artisan key:generate
```

Finally make sure you have a database named `spoon`, and run the migrations and seeds

```bash
php artisan migrate --seed
```

### Assets

Installing Spoon's front end dependencies requires `yarn`.

```bash
yarn
```

Spoon uses [Laravel Mix](https://laravel.com/docs/5.4/mix) to build assets.
To build assets run:

```bash
yarn run dev
```

Available build tasks are defined in `package.json`

## Colofon

### Contributing

Generally we won't accept any PR requests to Spoon. If you have discovered a bug or have an idea to improve the code, contact us first before you start coding.

### License

Spoon and The Laravel framework are open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
Loading

0 comments on commit e8f5dfc

Please sign in to comment.