Files to upload to ftp

After running yarn build:production and composer install --no-dev, bare minimum you’ll want:

├── app/
├── config/
├── dist/
├── resources/                 # Notice the lack of assets/ within here
│  ├── views/                  # Blade templates
│  ├── functions.php
│  ├── index.php
│  ├── screenshot.jpg
│  └── style.css
├── vendor/                    # Composer dependencies
└── LICENSE.md                 # Required (read it)

As I said, this is the technical bare minimum. It could be helpful to include the source/build files for whoever picks it up in the future. In my situation I want to encourage teammates to do things the right way (i.e. use version control for the codebase).

I have a bash script that I have run with yarn prep that builds for production and then packages these into an zipped folder, which I have labeled [theme-name]-distribute-[timestamp]-[commit hash]. It also includes some version details and instructions inside if someone stumbles upon the theme in the future. This allows me to stay sane whilst using FTP.

Prep script for Sage 9

Where yarn prep is yarn build:production && ./bin/prep.sh and ./bin/prep.sh is:

#!/bin/bash

# Get theme name
theme=${PWD##*/}

echo "Preparing $theme..."

# Get short hash of current commit
hash="$(git rev-parse --verify HEAD --short)"

# Get timestamp
timestamp="$(date '+%s')"

# Create temp directory
temp=".prep/$theme-$timestamp-$hash"
mkdir -p $temp

# Copy relevant files to the the directory
cp -R {app,config,dist,resources,vendor} $temp  # Theme setup & config, views, theme files, composer deps, & repo
rm -rf $temp/resources/assets                   # Remove source assets
cp LICENSE.md $temp                             # Copy Sage license (legally required)

# Create build(er) info and instructions file
printf "A theme by Example (example.com)\n\nCommit:   $hash\nBuilt at: $timestamp\nBuilt by: $(git config user.name)\n\n" > $temp/example.md
cat bin/instructions.md >> $temp/example.md

# Set distribute file name
dist="$theme-distribute-$timestamp-$hash".zip

# Compress distribution
cd .prep
zip -qr $dist "$theme-$timestamp-$hash"

# Remove temporary theme directory
rm -rf $theme

# Relocate distribution and current working directory
mv $dist ..
cd ..

echo "Finished!"

Probably could use some improvements, but it does the trick.

1 Like