Skip to content

Commit

Permalink
adding tailwind cli commands
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jun 25, 2024
1 parent 857b3ba commit 844318e
Show file tree
Hide file tree
Showing 83 changed files with 718 additions and 18 deletions.
30 changes: 20 additions & 10 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,42 @@

<rule ref="PSR12.Operators.OperatorSpacing.NoSpaceAfter">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/plugin/</exclude-pattern>
</rule>

<rule ref="PSR12.Operators.OperatorSpacing.NoSpaceBefore">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/plugin/</exclude-pattern>
</rule>

<rule ref="Eightshift.Security.HelpersEscape.OutputNotEscaped">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/plugin/</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/plugin/</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/standard/plugin/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/theme/</exclude-pattern>
<exclude-pattern>*/src/Init/tailwind/plugin/</exclude-pattern>
</rule>

<rule ref="Internal.NoCodeFound">
Expand Down
6 changes: 4 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ parameters:
- src/
excludePaths:
- src/**/*Example.php
- src/Init/theme/
- src/Init/plugin/
- src/Init/standard/theme/
- src/Init/standard/plugin/
- src/Init/tailwind/theme/
- src/Init/tailwind/plugin/
ignoreErrors:
# Ignore errors about reflection class variable being undefined. Errors are caught.
- '/^Variable \$reflectionClass might not be defined\.$/'
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/AbstractCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function prepareSetupArgs(array $args = []): array
self::ARG_SITE_URL => $args[self::ARG_SITE_URL] ?? \site_url(),
self::ARG_LIBS_VERSION => $args[self::ARG_LIBS_VERSION] ?? '',
self::ARG_FRONTEND_LIBS_VERSION => $args[self::ARG_FRONTEND_LIBS_VERSION] ?? '',
self::ARG_FRONTEND_LIBS_TYPE => $args[self::ARG_FRONTEND_LIBS_TYPE] ?? 'standard',
self::ARG_FRONTEND_LIBS_TYPE => \strtolower($args[self::ARG_FRONTEND_LIBS_TYPE] ?? 'standard'),
self::ARG_SKIP_EXISTING => true,
self::ARG_GROUP_OUTPUT => true,
];
Expand Down
3 changes: 2 additions & 1 deletion src/Init/InitPluginSetupCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ public function __invoke(array $args, array $assocArgs)
$assocArgs = $this->prepareSetupArgs($assocArgs);

$textdomain = $assocArgs[self::ARG_TEXTDOMAIN];
$frontendLibsType = $assocArgs[self::ARG_FRONTEND_LIBS_TYPE];

$this->getIntroText($assocArgs);

$sep = \DIRECTORY_SEPARATOR;
$dir = __DIR__ . "{$sep}plugin";
$dir = __DIR__ . "{$sep}{$frontendLibsType}{$sep}plugin";
$files = \array_diff(\scandir($dir), ['..', '.']);

$destionation = Helpers::getProjectPaths('pluginRoot');
Expand Down
3 changes: 2 additions & 1 deletion src/Init/InitThemeSetupCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ public function __invoke(array $args, array $assocArgs)
$assocArgs = $this->prepareSetupArgs($assocArgs);

$textdomain = $assocArgs[self::ARG_TEXTDOMAIN];
$frontendLibsType = $assocArgs[self::ARG_FRONTEND_LIBS_TYPE];

$this->getIntroText($assocArgs);

$sep = \DIRECTORY_SEPARATOR;
$dir = __DIR__ . "{$sep}theme";
$dir = __DIR__ . "{$sep}{$frontendLibsType}{$sep}theme";
$files = \array_diff(\scandir($dir), ['..', '.']);

$destionation = Helpers::getProjectPaths('themeRoot');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lintJs": "eslint src/ assets/",
"lint": "npm run lintJs && npm run lintStyle && composer standards:check -- --filter=gitstaged",
"start": "webpack --watch --mode development",
"build": "webpack --progress --mode production"
"build": "webpack --mode production"
},
"devDependencies": {
"husky": "^9.0.11",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
};

// Generate webpack config for this project using options object.
return require('./node_modules/@eightshift/frontend-libs/webpack')(argv.mode, projectConfig);
return require('@eightshift/frontend-libs/webpack')(argv.mode, projectConfig);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lintJs": "eslint src/ assets/",
"lint": "npm run lintJs && npm run lintStyle && composer standards:check -- --filter=gitstaged",
"start": "webpack --watch --mode development",
"build": "webpack --progress --mode production"
"build": "webpack --mode production"
},
"devDependencies": {
"husky": "^9.0.11",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/Init/tailwind/plugin/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defaults
not IE 11
not op_mini all
1 change: 1 addition & 0 deletions src/Init/tailwind/plugin/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public/**/*.js
3 changes: 3 additions & 0 deletions src/Init/tailwind/plugin/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/@eightshift/frontend-libs-tailwind/linters/eslint.config.js"
}
6 changes: 6 additions & 0 deletions src/Init/tailwind/plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Project Specific
/public
/vendor
/vendor-prefixed
/node_modules
.DS_Store
5 changes: 5 additions & 0 deletions src/Init/tailwind/plugin/.stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

{
"extends": "./node_modules/@eightshift/frontend-libs-tailwind/linters/stylelint.config.js",
"ignoreFiles": "public/**/*.css"
}
Empty file.
3 changes: 3 additions & 0 deletions src/Init/tailwind/plugin/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: './node_modules/@eightshift/frontend-libs-tailwind/babel/babel.config.js',
};
59 changes: 59 additions & 0 deletions src/Init/tailwind/plugin/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "%g_textdomain%/%g_textdomain%",
"description": "%g_project_description%",
"private": true,
"license": "MIT",
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v1.0.0",
"infinum/eightshift-coding-standards": "^3.0.0",
"php-stubs/wordpress-stubs": "^v6.5.3",
"szepeviktor/phpstan-wordpress": "^v1.3.4",
"wp-cli/wp-cli": "^v2.10.0"
},
"require": {
"php": ">=8.2"
},
"autoload": {
"psr-4": {
"%g_namespace%\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"optimize-autoloader": true,
"process-timeout": 2000,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"test:types": "@php ./vendor/bin/phpstan analyze",
"test:standards": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 8.2-",
"test": [
"@test:standards",
"@test:types"
],
"prefix-namespaces": [
"@php strauss.phar",
"composer dump-autoload"
],
"post-install-cmd": [
"@php strauss.phar",
"composer dump-autoload"
],
"post-update-cmd": [
"@php strauss.phar",
"composer dump-autoload"
]
},
"extra": {
"strauss": {
"namespace_prefix": "%g_namespace_vendor_prefix%",
"exclude_from_prefix": {
"file_patterns": ["/Example.php$/"]
}
}
}
}
95 changes: 95 additions & 0 deletions src/Init/tailwind/plugin/eightshift-boilerplate-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/**
* Plugin Name: %g_project_name%
* Description: %g_project_description%
* Author: %g_project_author%
* Author URI: %g_project_author_url%
* Version: %g_project_version%
* License: MIT
* License URI: http://www.gnu.org/licenses/gpl.html
* Text Domain: %g_textdomain%
*
* @package %g_namespace%
*/

declare(strict_types=1);

namespace %g_namespace%;

use %g_namespace%\Cache\ManifestCache;
use %g_namespace%\Main\Main;
use %g_use_libs%\Cli\Cli;

/**
* If this file is called directly, abort.
*/
if (! \defined('WPINC')) {
die;
}

/**
* Bailout, if the plugin is not loaded via Composer.
*/
if (!\file_exists(__DIR__ . '/vendor/autoload.php')) {
return;
}

/**
* Require the Composer autoloader.
*/
$loader = require __DIR__ . '/vendor/autoload.php';

/**
* Require the Composer autoloader for the prefixed libraries.
*/
if (\file_exists(__DIR__ . '/vendor-prefixed/autoload.php')) {
require __DIR__ . '/vendor-prefixed/autoload.php';
}

if (\class_exists(PluginFactory::class)) {
/**
* The code that runs during plugin activation.
*/
\register_activation_hook(
__FILE__,
function () {
PluginFactory::activate();
}
);

/**
* The code that runs during plugin deactivation.
*/
\register_deactivation_hook(
__FILE__,
function () {
PluginFactory::deactivate();
}
);
}

/**
* Set all the cache for the plugin.
*/
if (\class_exists(ManifestCache::class)) {
(new ManifestCache())->setAllCache();
}

/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*/
if (\class_exists(Main::class)) {
(new Main($loader->getPrefixesPsr4(), __NAMESPACE__))->register();
}

/**
* Run all WPCLI commands.
*/
if (\class_exists(Cli::class)) {
(new Cli())->load('boilerplate');
}
23 changes: 23 additions & 0 deletions src/Init/tailwind/plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "%g_textdomain%",
"description": "%g_project_description%",
"private": true,
"license": "MIT",
"scripts": {
"lintStyle": "stylelint **/*.scss",
"lintJs": "eslint src/ assets/",
"lint": "npm run lintJs && npm run lintStyle && composer standards:check -- --filter=gitstaged",
"start": "webpack --watch --mode development",
"build": "webpack --mode production"
},
"devDependencies": {
"husky": "^9.0.11",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
}
}
37 changes: 37 additions & 0 deletions src/Init/tailwind/plugin/phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<ruleset name="Eightshift Boilerplate ruleset">
<description>Ruleset for the Eightshift Boilerplate Plugin.</description>

<rule ref="Eightshift" />

<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/vendor-prefixed/*</exclude-pattern>
<exclude-pattern>*/public/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>

<!-- Additional arguments. -->
<arg value="sp"/>
<arg name="basepath" value="."/>
<arg name="parallel" value="8"/>
<arg name="extensions" value="php"/>

<file>.</file>

<!-- Check for PHP cross-version compatibility. -->
<config name="testVersion" value="8.2-"/>
<rule ref="PHPCompatibilityWP"/>

<!-- Support only latest 3 WP versions. -->
<config name="minimum_supported_wp_version" value="8.0"/>

<exclude-pattern>/src/CompiledContainer\.php</exclude-pattern>

<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="300" />
<property name="ignoreComments" value="true" />
</properties>
</rule>

</ruleset>
17 changes: 17 additions & 0 deletions src/Init/tailwind/plugin/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
level: 6
inferPrivatePropertyTypeFromConstructor: true
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- vendor-prefixed/autoload.php
paths:
- src/
ignoreErrors:
# Block templates
- '#^Variable \$attributes might not be defined\.#'
- '#^Variable \$renderContent might not be defined\.#'
- '#^Variable \$this might not be defined\.#'
- '#^Variable \$templatePath might not be defined\.#'
- identifier: missingType.generics
7 changes: 7 additions & 0 deletions src/Init/tailwind/plugin/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const autoprefixer = require('autoprefixer');

module.exports = {
plugins: [
autoprefixer,
],
};
Binary file added src/Init/tailwind/plugin/strauss.phar
Binary file not shown.
Loading

0 comments on commit 844318e

Please sign in to comment.