Skip to content
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

Templates improvement #286

Open
axeloz opened this issue Nov 21, 2016 · 3 comments
Open

Templates improvement #286

axeloz opened this issue Nov 21, 2016 · 3 comments

Comments

@axeloz
Copy link
Contributor

axeloz commented Nov 21, 2016

Hello,

Just some feature requests concerning the templates :

  • It takes quite some time to configure a project especially when this project requires a lot of steps to deploy properly. In this case, it is very complicated to create a template first and then the project.
    I would be nice to be able to generate a template from a project : when you're done configuring your project which deploys smoothely, you could click the "Generate template" button, give it a name and voila.

  • Also, it would be nice to be able to overwrite this template : if you improve the deployment process in the project, clicking the "Generate template" button should ask if you want to create a new template or overwrite an existing. This step is not mandatory as one could create a new template with a new name and delete the old one. But still, it's a nice to have.

  • Finally, when generating a project from a template, the project and the template are detached meaning that altering the template will not affect the project. Not a big deal but can become a pain when you have many projects generated from the same template and you have to fix something...

Thanks

Axel

@REBELinBLUE
Copy link
Owner

First one definitely makes a lot of sense and shouldn't be that complicated

Second seems reasonable, and I guess wouldn't be much work after doing the first part

Third one is slightly tricky, I was thinking of templates more like templates for say Microsoft Word, when you change a template file it doesn't change any existing word document using it. The reason for this is that the place I was working at when I originally wrote had a slight difference in the steps so each project so although they were set up from a template if the template changed we didn't want to existing projects to change.

I guess I can understand how it would be useful though as several people have asked for it, maybe I could add an option to "link" and/or "unlink" from the template when creating a project

@axeloz
Copy link
Contributor Author

axeloz commented Nov 28, 2016

Actually, I'm rethinking about this issue and I might have some changes to offer.
Instead of having a unique template, including all related objects of a project in the template, it could be convenient to have templates for each object.

For example : we work with Wordpress but we don't commit any Wordpress files in the repo. Instead we have a /theme and a /plugin folders. Then we use a Gulp task who will process everything (sass, minify, images...) and will copy the plugin and the theme folder into the wp-content.

So this kind of project, I have created a script for the deployer. The script will fetch two project variables named WORDPRESS_VERSION and WORDPRESS_LOCALE. According to this settings, the script will download the asked version of Wordpress in the right locale, then create the symlinks and move what needs to be moved.

There is the script if anyone interested :

# Checking whether Wordpress already installed
if [ ! -d {{ project_path }}/shared/wp ]
then
    echo "Now installing Wordpress"
    
    # Wordpress is not installed
    mkdir {{ project_path }}/shared/wp
    if [ $? -ne 0 ]
    then
        echo "Cannot create wp dir"
        exit 1
    fi

    cd {{ project_path }}/shared/wp

    # Searching the WP_Cli binary (http://wp-cli.org/)
    wp=`which wp`
    
    # Binary does not exist or is not executable
    if [ ! -x $wp ]
    then
        echo "WP_Cli executable could not be found"
        exit 1
    fi
    
    echo "We found the WP_Cli binary"

    # Downloading Wordpress
    $wp core download --locale=$WORDPRESS_LOCALE --version=$WORDPRESS_VERSION

    if [ $? -ne 0 ]
    then
        echo "Unable to download Wordpress"
        exit 1
    fi
    
    echo "Wordpress was downloaded"
    
    # Making sure the upload dir does not exist
    if [ -d ./wp-content/uploads ]
    then
        rm -Rf ./wp-content/uploads
        if [ $? -ne 0 ]
        then
            echo "Unable to remove the uploads folder"
        fi
        echo "Deleted uploads folder"
    fi

    # Making sure the plugin dir does not exist
    if [ -d ./wp-content/plugins ]
    then
        rm -Rf ./wp-content/plugins
        if [ $? -ne 0 ]
        then
            echo "Unable to remove the plugins folder"
        fi
        echo "Deleted plugins folder"
    fi

    # Making sure the wp-config.php file does not exist
    if [ -f ./wp-config.php ]
    then
        rm -f ./wp-config.php
        if [ $? -ne 0 ]
        then
            echo "Unable to remove the wp-config.php file"
        fi
        echo "Deleted wp-config.php file"
    fi
    
    # Making sure the theme dir does not exist
    if [ -d ./wp-content/themes ]
    then
        rm -Rf ./wp-content/themes
        if [ $? -ne 0 ]
        then
            echo "Unable to remove the themes folder"
        fi
        echo "Deleted themes folder"
    fi
fi

# Copying Wordpress into the release

cp -Rf {{ project_path }}/shared/wp/* {{ release_path }}
if [ $? -ne 0 ]
then
    echo "Unable to copy Wordpress to release"
    exit 1
fi


echo "Done"
exit 0

Well, I think this script could be a template itself. Meaning that when you add a step, you can choose this script as a template.

Just an idea...

Thanks

@uLow
Copy link
Contributor

uLow commented May 30, 2017

@REBELinBLUE don't want to argue about default steps, but it would be great to have templates for custom commands. One-type projects with big amount of post-install scripts are b-hurt when creating them one-by-one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants