BlackbirdDigital / wp-theme-scaffold

Blackbird's WordPress Theme Scaffold
GNU General Public License v2.0
30 stars 1 forks source link

May benefit from a theme setup script! #25

Open aurooba opened 2 years ago

aurooba commented 2 years ago

In my own scaffold, I have this thing in my gulpfile, to save myself from the search/replace life. You might find it helpful :) It uses gulp-prompt and gulp-replace, and keyed to a gulp setup command. It's a bit old and needs cleanup and refining, but it works really well and is so quick.

/**
 * Task: Get the Terms
 *
 * Creates multiple user prompts used during Setup to make the necessary changes to the theme
 *
 */
function get_the_terms() {
    return src(['*.php', '**/*.php', 'scss/style.scss']).pipe(
        prompt.prompt(
            [
                {
                    type: 'input',
                    name: 'theme',
                    message: 'Enter your theme name (e.g. WP Workflow Website):',
                },
                {
                    type: 'input',
                    name: 'textdomain',
                    message: "Enter your theme's text domain (e.g. wp-workflow):",
                },
                {
                    type: 'input',
                    name: 'url',
                    message: "Enter your theme's URL:",
                },
                {
                    type: 'input',
                    name: 'author',
                    message: 'Enter your name:',
                },
                {
                    type: 'input',
                    name: 'authorurl',
                    message: 'Enter your URL:',
                },
                {
                    type: 'input',
                    name: 'package',
                    message:
                        'Enter package name (e.g. workflow_supercharged, make sure spaces are underscores):',
                },
                {
                    type: 'input',
                    name: 'projecturl',
                    message: 'Enter your Local URL (without the protocol):',
                },
            ],
            (result) => {
                themename = result.theme;
                textdomain = result.textdomain;
                url = result.url;
                author = result.author;
                authorurl = result.authorurl;
                package = result.package;
                localurl = result.projecturl;
            },
        ),
    );
}

/**
 * Task: Replace the Terms in PHP (there's also one for SCSS but you get the idea)
 * (this needs some updating, but works for now)
 */
function replace_terms_in_php() {
    return src(['*.php', '**/*.php', '!build/**/*.php'])
        .pipe(replace('function workflow_supercharged', 'function ' + package))
        .pipe(replace('@package workflow_supercharged', '@package ' + package))
        .pipe(replace('workflow_supercharged', textdomain))
        .pipe(dest('.'));
}
cr0ybot commented 2 years ago

@aurooba Thanks, this has been on my mind but I haven't decided how I want to handle it yet. I appreciate the sample script!

I've got another repo for a potential Node package that would pull the scaffold and handle the search and replace, since it's just a one-time setup kind of thing. But it would also be useful to handle creating the .env file for local dev to set the local domain.

aurooba commented 2 years ago

Yes! A node package has been on my list forever. The gulp thing was always meant to be a stand-in.

I always thought it would be cool if the node package could pull in a scaffold of your choice with variables/replace-tokens defined and then the package could handle the search replace and stuff for you. I have about 3 scaffolds right now that I use based on the project complexity and type.

On Wed, Feb 16, 2022 at 4:41 PM Cory Hughart @.***> wrote:

@aurooba https://github.com/aurooba Thanks, this has been on my mind but I haven't decided how I want to handle it yet. I appreciate the sample script!

I've got another repo for a potential Node package that would pull the scaffold and handle the search and replace, since it's just a one-time setup kind of thing. But it would also be useful to handle creating the .env file for local dev to set the local domain.

— Reply to this email directly, view it on GitHub https://github.com/BlackbirdDigital/wp-theme-scaffold/issues/25#issuecomment-1042414810, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU2XTABWHLTJW55GX3DMYDU3QYZRANCNFSM5OTBW7KQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Cheers,

Aurooba Ahmed (she/her) https://aurooba.com

Office Hours: Monday to Thursday, 10am – 4pm Mountain Time