npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nomadmystic/wordpress-scaffold-cli

v0.8.6

Published

This project is created to speed up WordPress development

Downloads

10

Readme

WordPress Scaffold CLI

Installation

$ npm i -g @nomadmystic/wordpress-scaffold-cli

NOTE: This packages uses node version >=18.x

Commands

Help:
$ wps --help
Initialize Project
$ wps --pi
$ wps --project-init

Uses the WP-CLI to download the core files, creates the config needed for DB if specified, scaffolds internal files/folders, generates/updates JSON configs, adds common development files, installs the core DB and admin user, and initializes a git repo if not one already.

  • User Prompts:
    • Project Name (String), Namespace of your WordPress site, used in namespacing PHP classes
    • Database Setup (Boolean), Asks if you have setup a local DB for the site (NOTE: WILL OVERWRITE DB at the moment)
      • Database Name (String), DB name
      • Database Password (String), DB password
      • Database Username (String), DB Username
    • Site Title (String), Used in wp core install command
    • Site Admin User (String), Admin user for the site
    • Admin Email (String), Admin email
    • Site Admin Password (String), Admin password for the site
    • Site Url (String), Production URL for your site
    • Dev Site Url (String), Development URL for your site

$ ws-scaffold-plugin (Future Release)

Initialize Theme
$ wps --t
$ wps --theme
  • User Prompts:
    • Project Name (String), Namespace of your WordPress site, used in namespacing PHP classes
    • Theme Name (String), Name of your theme
    • Theme Description (String), Description for your theme
    • FrontEnd Framework (Array['None', 'Vue.js 3']), Choose if you want Vue.js added to your project
    • Site Url (String), Production URL for your site
    • Dev Site Url (String), Development URL for your site

Bootstrap Class and hook reflection

In both the plugin and theme scaffolding I include a BootstrapClasses class which auto instantiates classes it finds in the composer.json psr-4 namespaces object.

This uses reflection to hook directly into the WordPress hook system.

Doc Properties:

@add_action 
@add_filter
@priority (optional, defaults to 10)

Examples:

Filter:
/**
 * @description This filters the content
 * @add_filter the_content 
 * 
 * @param string $content
 * @return string
 */
public function some_filter_method(string $content): string
{
    // Do something with content
    
    return $content;
}
Action:
/**
 * @description This enqueues scripts
 * @add_action wp_enqueue_scripts
 * 
 * @return void
 */
public function some_action_method(): void
{
    // Enqueue some scripts
}
Action with Priority:
/**
 * @description This enqueues scripts
 * @add_action wp_enqueue_scripts
 * @priority 100
 * 
 * @return void
 */
public function some_action_method(): void
{
    // Enqueue some scripts
}

Setup

Create WordPress Project

User will need to take care of setting up hosts and DNS. Not going to scaffold this because of 
varying local setups. i.e. apache/Nginx bare-metal, Docker e.t.c

DB Setup

$ sudo mysql
$ CREATE DATABASE <DATABSE_NAME>;
$ GRANT ALL PRIVILEGES ON <DATABSE_NAME>.* TO "<DATABASE_USER>"@"localhost" IDENTIFIED BY "<DATABASE_PASSWORD>";
$ FLUSH PRIVILEGES;
$ EXIT;

Project Setup

$ mkdir <YOUR_PROJECT_NAME>
$ cd <YOUR_PROJECT_NAME>
$ wps --project-init

Theme Setup

$ cd <YOUR_PROJECT_NAME>
$ wps --theme

Development

Initial Setup

$ git clone [email protected]:nomad-mystic/wordpress-scaffold-cli.git ./scaffold-cli
$ cd scaffold-cli
$ nvm use
$ npm i
$ npm run dev:tsc | npm run dev | npm run production:build 

Local dev commands

$ npm run dev:wps -- --version
$ npm run dev:wps -- --help
$ npm run dev:wps -- --project-init
$ npm run dev:wps -- --theme
$ npm run dev:wps -- --plugin

Package Testing

$ npm pack ./ --pack-destination="<PATH_TO_FOLDER>"
$ cd <PATH_TO_FOLDER>
$ npm i -g <PACKAGE_NAME>
$ cd <YOUR_PROJECT_NAME>
$ wps --help
$ wps --version

For testing this package in a non-WordPress root folder copy ./env.example to ./.env and update values

Resources

  • https://wordpress.org/support/article/creating-database-for-wordpress/
  • https://wp-cli.org/
  • https://getcomposer.org/doc/
  • https://vuejs.org/
  • https://sass-lang.com/
  • https://webpack.js.org/
  • https://github.com/nvm-sh/nvm