Skip to content

Commit

Permalink
Merge pull request #30 from dreamsicle-io/release/1.2.0-RC2
Browse files Browse the repository at this point in the history
Release/1.2.0 rc2
  • Loading branch information
theenoahmason authored Feb 22, 2024
2 parents 05ef4da + 716bcf7 commit 2c03ec4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ WP Version Required: (5.0.0)
WP Version Tested: (5.0.0)
Function Prefix: (wp_theme)
Class Prefix: (WP_Theme)
Constant Prefix: (WP_THEME)
Path: ()
```

Expand All @@ -58,7 +59,6 @@ The tool will log its progress and errors in the console, exiting on completion
Creating theme: WP Theme in C:\Users\noahm\Code\create-wp-theme-dev\app\public\wp-content\themes\my-theme

Repo cloned: https://github.com/dreamsicle-io/wp-theme-assets.git --> C:\Users\noahm\Code\create-wp-theme\tmp
package-lock.json cleaned: C:\Users\noahm\Code\create-wp-theme\tmp\package\package-lock.json
package.json written: C:\Users\noahm\Code\create-wp-theme\tmp\package\package.json
File Renamed: C:\Users\noahm\Code\create-wp-theme\tmp\package\includes\class-wp-theme-assets.php
File built: C:\Users\noahm\Code\create-wp-theme\tmp\package\includes\class-wp-theme-assets.php
Expand Down Expand Up @@ -123,6 +123,7 @@ Options:
"5.0.0")
-F, --functionPrefix [string] The prefix for PHP functions (default: "wp_theme")
-C, --classPrefix [string] The prefix for PHP classes (default: "WP_Theme")
-c, --constantPrefix [string] The prefix for PHP constants (default: "WP_THEME")
-p, --path [string] The path where the built theme directory will be placed. (default:
"C:\\Users\\noahm\\source\\repos\\create-wp-theme")
-h, --help display help for command
Expand Down
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const defaultArgs = {
wpVersionTested: '5.0.0',
functionPrefix: 'wp_theme',
classPrefix: 'WP_Theme',
constantPrefix: 'WP_THEME',
path: process.cwd(),
};

Expand All @@ -54,6 +55,7 @@ const argTypes = {
wpVersionTested: 'string',
functionPrefix: 'string',
classPrefix: 'string',
constantPrefix: 'string',
path: 'string',
};

Expand All @@ -75,6 +77,7 @@ const argTitles = {
wpVersionTested: 'WP Version Tested',
functionPrefix: 'Function Prefix',
classPrefix: 'Class Prefix',
constantPrefix: 'Constant Prefix',
path: 'Path',
};

Expand All @@ -96,6 +99,7 @@ const argDescriptions = {
wpVersionTested: 'The version of WordPress the theme has been tested up to',
functionPrefix: 'The prefix for PHP functions',
classPrefix: 'The prefix for PHP classes',
constantPrefix: 'The prefix for PHP constants',
path: 'The path where the built theme directory will be placed.',
};

Expand All @@ -117,6 +121,7 @@ const argAliases = {
wpVersionTested: 'w',
functionPrefix: 'F',
classPrefix: 'C',
constantPrefix: 'c',
path: 'p',
};

Expand Down Expand Up @@ -145,6 +150,7 @@ const tmpPath = path.join(__dirname, 'tmp');
const tmpThemePath = path.join(tmpPath, 'package');
const tmpThemePkgPath = path.join(tmpThemePath, 'package.json');
const tmpThemePkgLockPath = path.join(tmpThemePath, 'package-lock.json');
const tmpThemeComposerLockPath = path.join(tmpThemePath, 'composer.lock');
const tmpThemeGulpPath = path.join(tmpThemePath, 'gulpfile.js');
const tmpThemeLicPath = path.join(tmpThemePath, 'LICENSE');
const themeDirName = changeCase.paramCase(program.args[0]);
Expand Down Expand Up @@ -272,9 +278,10 @@ function replaceRename(args = null) {
file = newFile;
}
var content = fs.readFileSync(file, 'utf8');
if (/WP Theme/g.test(content) || /WP_Theme/g.test(content) || /wp-theme/g.test(content) || /wp_theme/g.test(content)) {
if (/WP Theme/g.test(content) || /WP_Theme/g.test(content) || /WP_THEME/g.test(content) || /wp-theme/g.test(content) || /wp_theme/g.test(content)) {
content = content
.replace(/WP Theme/g, args.themeName)
.replace(/WP_THEME/g, args.constantPrefix.replace(/[^a-zA-Z\d]/g, '_'))
.replace(/WP_Theme/g, args.classPrefix.replace(/[^a-zA-Z\d]/g, '_'))
.replace(/wp-theme/g, themeDirName)
.replace(/wp_theme/g, changeCase.snakeCase(args.functionPrefix));
Expand All @@ -287,10 +294,10 @@ function replaceRename(args = null) {
}

function writePackage(args = null) {
del([tmpThemePkgLockPath], { force: true })
del([tmpThemePkgLockPath, tmpThemeComposerLockPath], { force: true })
.then(function (paths) {
if (paths.length > 0) {
console.info(chalk.bold.yellow('package-lock.json cleaned:'), paths.join(', '));
console.info(chalk.bold.yellow('Lock files cleaned:'), paths.join(', '));
}
fs.readFile(tmpThemePkgPath, function (error, data) {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dreamsicle.io/create-wp-theme",
"version": "1.1.1",
"version": "1.2.0",
"description": "A command line tool for creating modern, optimized WordPress themes.",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 2c03ec4

Please sign in to comment.