@penskemediacorp/wordpress-scripts
v2.0.0
Published
This repository hosts a collection of scripts designed to enhance your experience and efficiency when working with the PMC WordPress site. This package builds upon and extends the capabilities of the official @wordpress/scripts package, providing addition
Keywords
Readme
PMC WordPress Scripts
This repository hosts a collection of scripts designed to enhance your experience and efficiency when working with the PMC WordPress site. This package builds upon and extends the capabilities of the official @wordpress/scripts package, providing additional tools and functionalities tailored specifically for the PMC WordPress environment.
Features
Streamlined Workflows: Simplify the process of theme and plugin development with workflows tailored for efficiency.
Automation Scripts: Utilize custom scripts to automate repetitive tasks, saving time and reducing errors.
Enhanced WordPress Scripts: Benefit from enhancements to standard WordPress scripts that offer increased functionality and improved productivity.
TypeScript Support: Incorporate TypeScript into your development with enforced coding standards and type-checking, ensuring cleaner and more robust code.
Installation
Follow these steps to seamlessly incorporate the scripts into your WordPress project:
Install npm: Ensure that npm is installed on your system. If it is not installed, download and install it from the official npm website.
Install the PMC WordPress Scripts Package: Open your terminal, navigate to the root of your project, and execute the following commands:
nvm install 20 npm install @penskemediacorp/wordpress-scripts --save-devCommit Necessary Files: After installation, commit the tsconfig.json, package.json, and package-lock.json files to your project repository.
By following these steps, the scripts will be added to the devDependencies section of your project, enabling their use within your development workflow.
Project Folder Structure
The project main entries files should be placed under src folder.
The generated files will be placed under build folder.
build/(generated by the build script)- main-entry1.js
- main-entry1.asset.php
- main-entryX.js
- main-entryX.asset.php
- ...
src/(individual entry file under this folder will be generated inbuildfolder)- __tests__/
- main-entry1.test.ts
- main-entryX.test.ts
- ...
- modules/
- __tests__/
- module1.test.ts
- ...
- module1.ts
- ...
- __tests__/
- folderX/
- ...
- main-entry1.ts
- main-entryX.ts
- ...
- __tests__/
Usage
Contributing
The scripts block in package.json is hand-maintained
The scripts block in this package's own package.json is hand-maintained — in
particular the postinstall hook (pmc-scripts sync) is what wires this wrapper
into a consuming project.
That same hook used to be a footgun: running npm install (or npm run
packages-update, which installs under the hood) fired pmc-scripts sync
against this repo itself, rewriting its own scripts block with the defaults
meant for consumers. This is now prevented in code — updateProjectPackageJson()
/ updateProjectTsConfigJson() in utils/config.js bail out via isSelf() when
the sync target resolves to this package's own package.json, so the sync only
ever mutates a consuming project. See test/config.test.js.
If you ever do see a diff touching the scripts block (e.g. from a future
tooling change), revert only that block to its committed state — do not
blanket-revert the whole file (e.g. git restore package.json), since that would
also discard any legitimate dependency-version updates you want to keep.
