Skip to content

Allow writeFiles to omit resource for inline file trees - #4359

Merged
adamziel merged 8 commits into
trunkfrom
writeFiles-without-esource
Sep 29, 2026
Merged

adamziel merged 8 commits into
trunkfrom
writeFiles-without-esource

Conversation

@fellyph

@fellyph fellyph commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation for the change, related issues

A v1 Blueprint using writeFiles with an inline { name, files } tree fails schema validation even though the step can write that tree and the documented example omits resource. Fixes #2136.

Implementation details

  • Accept inline filesTree values without resource in the v1 type and generated schema and validator.
  • Preserve explicit literal:directory and git:directory resources and other steps' resource requirements.
  • Update the generated handbook text and add schema and runtime tests.

The v2 validator change only renames an internal generated schema alias; it does not change v2 validation.

Testing Instructions (or ideally a Blueprint)

  • npm exec -- nx build playground-blueprints
  • npm exec -- nx build docs-site
  • npm exec -- nx run playground-blueprints:test:vite --testFiles=src/tests/schema/public-schema.spec.ts (27 passed)
  • npm exec -- nx run playground-blueprints:test:vite --testFiles=src/tests/v1/compile.spec.ts (30 passed)
  • npm exec -- nx typecheck playground-blueprints
  • npm exec -- nx lint playground-blueprints

The unfiltered package suite could not complete in the restricted sandbox because unrelated tests require network and loopback socket access. The targeted runtime test passed with loopback access.

Example Blueprint step:

{
  "step": "writeFiles",
  "writeToPath": "/wordpress/wp-content/plugins/example",
  "filesTree": {
    "name": "example",
    "files": { "plugin.php": "<?php /* Plugin Name: Example */" }
  }
}

Summary by CodeRabbit

  • New Features
    • writeFiles now accepts inline directory structures without a resource property, while continuing to support explicit literal:directory and git:directory resources.
    • Inline directories require a name and files property; nested directories and file contents are supported.
  • Documentation
    • Clarified how to specify root directory names and map paths to file contents or nested directories.

@github-actions github-actions Bot added [Package][@wp-playground] Blueprints [Type] Documentation Improvements or additions to documentation labels Sep 24, 2026
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8ff1c4b3-12f7-4eb2-a8de-56d193a6b8c8

📥 Commits

Reviewing files that changed from the base of the PR and between 5487a78 and fc0f36f.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d8a3d0b4-ddd9-4887-90cb-0ab299b38010

📥 Commits

Reviewing files that changed from the base of the PR and between 1e5f73b and 5487a78.

📒 Files selected for processing (7)
  • packages/docs/site/static/handbook/blueprints-steps.md
  • packages/playground/blueprints/public/blueprint-schema-validator.js
  • packages/playground/blueprints/public/blueprint-schema.json
  • packages/playground/blueprints/public/blueprint-v2-schema-validator.js
  • packages/playground/blueprints/src/lib/steps/write-files.ts
  • packages/playground/blueprints/src/tests/schema/public-schema.spec.ts
  • packages/playground/blueprints/src/tests/v1/compile.spec.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The writeFiles.filesTree contract now accepts inline directories without a resource property, as well as explicit literal:directory and git:directory resources. The public schemas, generated validators, documentation, and tests reflect this form.

Changes

Inline writeFiles directory support

Layer / File(s) Summary
Update the filesTree contract and schemas
packages/playground/blueprints/src/lib/steps/write-files.ts, packages/playground/blueprints/public/blueprint-schema.json, packages/playground/blueprints/public/blueprint-schema-validator.js, packages/playground/blueprints/public/blueprint-v2-schema-validator.js
The TypeScript type and public schemas accept inline directories with required files and name fields. Generated validators check the inline form. Generated schema references use a renamed recursive-value alias.
Document and test inline directories
packages/docs/site/static/handbook/blueprints-steps.md, packages/playground/blueprints/src/tests/schema/public-schema.spec.ts, packages/playground/blueprints/src/tests/v1/compile.spec.ts
Documentation describes inline and referenced directory forms. Tests check accepted and rejected inputs, and verify that running a blueprint writes top-level and nested files.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: adamziel

Merge Risk: ⚪ Minimal · up to 5487a

Inline file trees appear supported across validation and execution, with no identified issue requiring a fix before merge.

🚥 Pre-merge checks | ✅ 5

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing inline writeFiles file trees to omit the resource property.
Linked Issues check ✅ Passed Issue #2136 requires v1 writeFiles.filesTree to work without resource. The type now accepts an inline Directory with optional resource. The generated v1 schema and validator accept inline `{ n…
Out of Scope Changes check ✅ Passed The changes stay within the issue scope. The documentation and tests support the new writeFiles form. The generated v1 schema and validator implement the validation change. The v2 validator changes …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@adamziel
adamziel merged commit bec74cf into trunk Sep 29, 2026
57 of 58 checks passed
@adamziel
adamziel deleted the writeFiles-without-esource branch September 29, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package][@wp-playground] Blueprints [Type] Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blueprints: filesTree seems requires a resource property

2 participants