Skip to content

Commit

Permalink
README.md for _bin and workflows folder + removed unnecesary scripts …
Browse files Browse the repository at this point in the history
…in package.json + general .cursorrules
  • Loading branch information
juanmaguitar committed Jan 5, 2025
1 parent 9101d87 commit b941315
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 144 deletions.
5 changes: 5 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
IMPORTANT: Document changes on each step in a `CHANGELOG.md` file.

- Create a new minor version on each session and add the current date beside that version
- Add patches version on each new set of changes added to `CHANGELOG.md`
- Place newer changes (and latest versions) first in `CHANGELOG.md`
72 changes: 72 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# GitHub Workflows

This directory contains GitHub Actions workflows that automate various tasks in the repository. Below is an overview of each workflow:

## Main Workflows

### 🚀 Zips on Deploy Branch (`main.yml`)

Handles the deployment process when changes are pushed to the trunk branch:

- Merges trunk branch into deploy branch
- Installs dependencies
- Runs deployment tasks
- Commits and pushes changes to deploy branch

### 🔍 Static Linting (`pull-request-actions.yml`)

Runs linting checks on pull requests and trunk branch pushes:

- PHP file linting
- JavaScript file linting
- CSS file linting
- Runs on Node.js 18 and latest LTS versions

## Data Management Workflows

### 👥 Update GitHub Contributors (`github-contributors.yml`)

Updates the list of project contributors:

- Fetches contributor information
- Updates `_data/examples.json`
- Can be manually triggered

### 📊 Contributor Details (`contributor-details.yml`)

Maintains detailed contributor information:

- Fetches detailed contributor data
- Updates `_data/contributors.json`
- Can be manually triggered

### 📅 Update Creation and Modification Dates (`update-dates.yml`)

Maintains file metadata:

- Updates creation and modification dates
- Updates `_data/examples.json`
- Runs monthly and can be manually triggered

## Scripts

The `scripts/` directory contains shell scripts used by these workflows:

- `fetch_contributors.sh`: Fetches basic contributor information
- `fetch_contributor_details.sh`: Retrieves detailed contributor data
- `update_dates.sh`: Updates file timestamps

## Permissions

Most workflows require write permissions to:

- Push changes to branches
- Update JSON data files
- Commit changes

## Triggers

- `main.yml`: Triggered on push to trunk branch
- `pull-request-actions.yml`: Triggered on pull requests and trunk pushes
- `update-dates.yml`: Runs monthly and manual trigger
- Others: Can be manually triggered via workflow_dispatch
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,3 @@ _app/build

*.code-workspace
_app/src/data
.cursorrules
35 changes: 30 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
# Changelog

## [1.2.2] - 2024-03-20
## [1.2.5] - 2025-01-05

### Added

- Created comprehensive README.md in \_bin directory
- Added documentation for available scripts
- Added directory structure overview
- Added development guidelines
- Added usage instructions for utility scripts

## [1.2.4] - 2024-12-21

### Changed

- Modified table generation to show only relevant example in each plugin's README.md
- Updated `npm run table:update:all` to respect single example per README rule

## [1.2.3] - 2024-12-21

### Added

- Support for generating table for a single example by passing its slug
- Added validation for example slug existence
- Enhanced error messages for missing examples

## [1.2.2] - 2024-12-20

### Fixed

- Added extensive debug logging to fetch_contributors.sh
- Added type checking for GitHub API responses
- Improved error handling for malformed API responses

## [1.2.1] - 2024-03-20
## [1.2.1] - 2024-12-20

### Fixed

- Fixed GitHub API response parsing in fetch_contributors.sh
- Added better error handling for invalid API responses
- Added null check for commit authors

## [1.2.0] - 2024-03-20
## [1.2.0] - 2024-12-20

### Changed

Expand All @@ -29,7 +54,7 @@
- Improved contributor deduplication logic
- Better error handling for API requests

## [1.1.0] - 2024-03-19
## [1.1.0] - 2024-12-19

### Added

Expand Down Expand Up @@ -72,7 +97,7 @@
- Added examples.json with block development examples
- Added tags.json with initial tag definitions

## 0.2.0 - 2024-03-21
## 0.2.0 - 2024-12-18

### 0.2.5

Expand Down
10 changes: 5 additions & 5 deletions _bin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changelog

All notable changes to the build scripts will be documented in this file.
All notable changes to the build scripts are documented in this file.

## [0.1.4] - 2024-03-XX
## [0.1.4]

### Changed

Expand Down Expand Up @@ -33,7 +33,7 @@ All notable changes to the build scripts will be documented in this file.
- Eliminated redundant error handling boilerplate
- Removed unnecessary path construction duplication

## [0.1.3] - 2024-03-XX
## [0.1.3]

### Added

Expand Down Expand Up @@ -96,7 +96,7 @@ All notable changes to the build scripts will be documented in this file.
- Removed extra tabs in TableMarkdownService
- Fixed line endings in error type definitions

## [0.1.2] - 2024-03-XX
## [0.1.2]

### Added

Expand All @@ -122,7 +122,7 @@ All notable changes to the build scripts will be documented in this file.
- Improved template literal formatting
- Simplified table generation formatting

## [0.1.1] - 2024-03-XX
## [0.1.1]

### Added

Expand Down
179 changes: 48 additions & 131 deletions _bin/README.md
Original file line number Diff line number Diff line change
@@ -1,146 +1,63 @@
# Block Development Examples - Build Scripts
# \_bin Directory Scripts

This folder contains utility scripts for managing WordPress block development examples. These scripts help automate various tasks like creating new examples, updating documentation, and managing the codebase.
This directory contains utility scripts used for managing and maintaining the Block Development Examples project.

## Directory Structure
## Available Scripts

```
_bin/
├── copyGutenbergExample/ # Scripts for copying/creating new examples
├── utils/ # Shared utility functions
├── _addExamplesPerTagReadme.js
├── constants.js
├── prepareDataForApp.js
└── updateTableMarkdown.js
```
You can run these scripts using the npm/pnpm commands defined in the root `package.json`:

## Available Scripts
### Table Generation

### Creating Examples
### Updating Documentation

```bash
# Create a new example by copying an existing one
npm run create-example:copy
- `npm run table:update` - Generates the main examples table in the root README.md
- `npm run table:update [example-slug]` - Update README table for a specific example
- `npm run table:update:all` - Updates all tables in the project documentation

# Create a brand new example from template
npm run create-example:new
```
### Contributors Management

The `create-example:copy` script launches an interactive CLI that:
1. Prompts you to select a source example
2. Asks for a new example name
3. Generates a unique ID
4. Lets you select tags
5. Creates the new example with customized files
- `npm run contributors:update` - Updates the contributors information in documentation

### Updating Documentation
### Date Management

```bash
# Update README table for a specific example
npm run table:update [example-slug]
- `npm run dates:update` - Updates dates across the project files

# Update all README tables
npm run table:update:all
```
## Script Files Structure

### Utility Scripts
The scripts are organized in the following structure:

```bash
# Generate a random hex code (used for example IDs)
npm run get:hexcode
```
.
├── CHANGELOG.md
├── README.md
├── src
│ ├── constants.ts
│ ├── index.ts
│ ├── services
│ │ ├── DatesService.ts
│ │ └── tableMarkdown.ts
│ ├── types
│ │ ├── config.ts
│ │ ├── errors.ts
│ │ └── example.ts
│ └── utils
│ ├── compose.ts
│ ├── errors.ts
│ ├── fileOperations.ts
│ ├── logging.ts
│ └── validation.ts
└── tsconfig.json
```

## Development

The scripts are written in TypeScript and use various utilities to manage project documentation and metadata. To modify or extend these scripts:

1. Navigate to the appropriate file in the `src` directory
2. Make your changes
3. Run `pnpm build` to compile if necessary
4. Test your changes using the corresponding npm script

## Note

## Core Files Explained

### copyGutenbergExample/
- `index.js` - Main entry point for example creation wizard
- `initCreateExample.js` - Handles the example creation process
- `customizeBlockJson.js` - Updates block.json for new examples
- `customizePackageJson.js` - Updates package.json for new examples
- `addExamplesJson.js` - Adds new example to examples.json registry
- `duplicateExampleNewName.js` - Handles folder duplication

### utils/
- `generateExamplesTableMarkdown.js` - Generates markdown tables for documentation
- `log.js` - Consistent logging utilities with color support
- `randomHexCode.js` - Generates unique example IDs

### Root Files
- `constants.js` - Shared configuration and constants
- `prepareDataForApp.js` - Processes data for the web application
- `updateTableMarkdown.js` - Updates README.md tables
- `_addExamplesPerTagReadme.js` - Manages tag-based documentation

## Key Features

1. **Example Management**
- Create new examples from existing ones
- Generate unique IDs for examples
- Customize block and package configurations
- Update documentation automatically

2. **Documentation**
- Auto-generate markdown tables
- Maintain tag-based organization
- Keep README files in sync

3. **Development Tools**
- Random ID generation
- Consistent logging
- File operation utilities

## File Operations

The scripts handle several types of files:
- `block.json` - Block configuration
- `package.json` - Package configuration
- `examples.json` - Example registry
- `README.md` - Documentation files

## Data Structure

Examples are organized with:
- Unique slug/ID combinations
- Associated tags
- Descriptions
- Related files and configurations

## Best Practices

1. Always use the provided scripts for:
- Creating new examples
- Updating documentation
- Managing configurations

2. Maintain consistent formatting:
- Use provided logging utilities
- Follow existing naming conventions
- Keep documentation up-to-date

3. Error Handling:
- Scripts include basic error handling
- Check console output for issues
- Verify file operations completed successfully

## Dependencies

Key dependencies used by these scripts:
- `@inquirer/prompts` - Interactive CLI
- `chalk` - Console styling
- `execa` - Process execution
- `fs-extra` - Enhanced file operations
- `markdown-table` - Table generation
- `replace-in-file` - File content updates

## Contributing

When modifying these scripts:
1. Maintain TypeScript-style type safety
2. Follow functional programming patterns
3. Update documentation as needed
4. Test thoroughly before committing

## Related Documentation

- [Block Development Examples Wiki](https://github.com/WordPress/block-development-examples/wiki)
- [WordPress Block Development](https://developer.wordpress.org/block-editor/)
These scripts are essential for maintaining project consistency and automating routine tasks. Always run them from the root directory of the project.
Loading

0 comments on commit b941315

Please sign in to comment.