Skip to content

Commit

Permalink
chore: Add backstage configuration and update relevant documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
wodnikm-news committed Nov 6, 2024
1 parent 0d841d5 commit fc7ef7f
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 24 deletions.
71 changes: 47 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
### NUK WP PHPCS config
# nuk-wp-phpcs-config

This library contains WordPress VIP PHPCS configuration for NewsUK plugins and themes.

## Requirements
- PHP 8.2
- WordPress 6.2
## Architecture

### Project Structure

```text
- .circleci # CircleCI pipeline configuration files
- .github # GitHub configuration files
- NewsPress # NewsPress phpcs rulesets
- NewsUK # NewsUK phpcs rulesets
```

## Technical Documentation

- [Package Extensibility](docs/extensibility.md)

## Contribution

More details on how to contribute to this package can be found in the [CONTRIBUTING.md](docs/CONTRIBUTING.md) file.

### Minimal requirements

- PHP 8.2
- WordPress 6.2

## Development setup

To build the package

PHP setup

- `composer install`

## Installation

Expand All @@ -14,7 +42,10 @@ Composer install:
composer require --dev newsuk/nuk-wp-phpcs-config
```

## Using the ruleset
## Usage

### Using the ruleset

Create a `phpcs.xml.dist` file in your project and add the following to use `NewsUK` ruleset:

```xml
Expand All @@ -23,29 +54,21 @@ Create a `phpcs.xml.dist` file in your project and add the following to use `New
<rule ref="NewsUK"/>
</ruleset>
```
💡 *It is recommended to use the `NewsUK` or `NewsPress` ruleset as it is without customising or overriding rules unless necessary.*

## Override or add custom rules
You can also override or add custom rules to the config as follows.
💡 *It is recommended to use the `NewsUK` or `NewsPress` ruleset as it is without customising or overriding rules unless necessary.*

```xml
<?xml version="1.0"?>
<ruleset name="NewsUK WP PHPCS Rules">
<rule ref="NewsUK"/>
<!-- Overriding the existing text_domain -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="your_plugin_domain"/>
</property>
</properties>
</rule>
</ruleset>
```
## Composer scripts
### Usage with Composer
Add the following to `scripts` section in `composer.json` file to run linting.

```json
"lint": "phpcs .",
"lint:fix": "phpcbf .",
```
```

## Tagging and releasing

The content schema uses Semantic Versioning `semver` for versioning. The package is released using [GitHub Releases](https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/about-releases). The release process is automated in Circle CI build step. To create a new release, follow these steps:

- Update the relevant files with the new version. Commit the updated files.
- Push the changes to the master branch, by merging the associated pull request
- Create a release targeting the `master` branch within GitHub.
18 changes: 18 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: nuk-wp-phpcs-config
description: PHPCS configuration for WordPress VIP plugins and themes.
tags:
- wordpress
- phpcs
- php
- coding-standards
- bu:newsuk
annotations:
circleci.com/project-slug: github/newsuk/nuk-wp-phpcs-config
jira/project-key: CPNT
spec:
type: library
lifecycle: development
owner: group:newsuk
17 changes: 17 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contributing

This package is maintained by the Times CMS team.

## Code Contribution

Developers from outside the team are encouraged to contribute back to this package as part of fix and feature requests. In doing so, developers should ensure their changes adhere to established naming conventions within the package.

## Branching

The `main` branch is the source of truth for the repo. Example: `feat/JIRA-ID-magic-wand` branch should be cut from `main` and used as the base for any development work. Feature and fix branches should be cut from the `main` branch, and follow the `feat/JIRA-ID-*`, `fix/JIRA-ID-*` naming convention. Pull requests for these branches should be targeted at the `main` branch. The branching strategy and the release process is documented [here](https://nidigitalsolutions.jira.com/wiki/spaces/NCP/pages/2329149445/Branching+and+Deployment).

## Commit Messages

Commit messages should follow the Conventional Commits spec, `type(issue-ref): description`

For example, a feature update for issue CPNT-123 that adds a new text box might have a commit message like "feat(CPNT-123): add new text box"
26 changes: 26 additions & 0 deletions docs/GETTINGSTARTED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Getting Started

This reference is intended for developers prior to starting work on this package.

## Development Tools

Developers should have the following installed at a minimum:

- Git
- PHP
- Composer

## Branching and Release

Please review the documentation about tagging and release process be found in the [README](../README.md#tagging-and-releasing) prior to starting development. More details on branching can be found in [CONTRIBUTING](./CONTRIBUTING.md#branching).

## File Structure

PHP: PHP files should primarily be organized in the top-level `inc` directory.

JavaScript: JS files should be organized in the top-level `src` directory.

## Additional Support

Further questions can be directed to the Times CMS team in the [`#tm-timescms-team` Slack channel](https://newscorp.enterprise.slack.com/archives/C03JD1PU44B).

3 changes: 3 additions & 0 deletions docs/HELPWANTED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Help Wanted

This file should contain any TODO items for the project with which the Times CMS team would appreciate assistance.
22 changes: 22 additions & 0 deletions docs/extensibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Package Extensibility

This package provides many ways for developers to customise the behaviour.

## Ruleset overriding and adding custom rules

You can also override or add custom rules to the config as follows.

```xml
<?xml version="1.0"?>
<ruleset name="NewsUK WP PHPCS Rules">
<rule ref="NewsUK"/>
<!-- Overriding the existing text_domain -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="your_plugin_domain"/>
</property>
</properties>
</rule>
</ruleset>
```

0 comments on commit fc7ef7f

Please sign in to comment.