Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add resource type URL to writeFiles step #2143

Open
bph opened this issue Feb 11, 2025 · 0 comments
Open

Feature: Add resource type URL to writeFiles step #2143

bph opened this issue Feb 11, 2025 · 0 comments

Comments

@bph
Copy link
Collaborator

bph commented Feb 11, 2025

During the update of the blueprints, I tried to use the step writeFiles like this (which didn't work)

"step": "writeFiles",
		"writeToPath": "/wordpress/wp-content",
		"filesTree": {
		  "resource": "literal:directory",
		  "name": "wp-content",
		  "files": {
			"postcontent.md": {
			  "resource": "url",
			  "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/postcontent.md"
			},
			"Select-storage-method.png": {
			  "resource": "url",
			  "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/Select-storage-method.png"
				}
			  }
			}

@bgrgicak took another look at this and found the following:

Your original Blueprint created a directory with the name postcontent.md and added files named resource and url to the directory.

Image

This behavior matches our implementation of writeFile where a file can only be a literal value or another file tree (represented as a JSON object in the Blueprint).

"It would be mind blowing if we could append resource types like URLs in the way you attempted it, so it might be worth submitting a feature request to start a discussion." -- @bgrgicak

I strongly agree. It feels natural and allows for a more organized approach.

this is the current working implementation using writeFile step.

{
			"step": "writeFile",
			"path": "/wordpress/wp-content/postcontent.md",
			"data": {
				"resource": "url",
				"url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/postcontent.md"
			}
		},
		{
			"step": "writeFile",
			"path": "/wordpress/wp-content/Select-storage-method.png",
			"data": {
				"resource": "url",
				"url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/wpcli-post-with-image/Select-storage-method.png"
			}
		},

It could look like this or something similar

{
"step": "writeFiles",
		"writeToPath": "/wordpress/wp-content",
		"filesTree": {
		  "resource": "literal:directory",
		  "name": "wp-content",
		  "files": {
			"postcontent": {
			        "resource": "url",
			         "postcontent.md": "https://github.com/WordPress/blueprints/blob/trunk/blueprints/wpcli-post-with-image/postcontent.md"
                                 },
			      { 
                               "resource": "url",
			        "Select-storage-method.png": "https://github.com/WordPress/blueprints/blob/trunk/blueprints/wpcli-post-with-image/Select-storage-method.png"}
			  }
	         }
	}
}

this would place the two files into the same directory

±---/wp-content
       |------/postcontent/
                     |-- postcontent.md
                     |--  Select-storage-method.png       
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Inbox
Development

No branches or pull requests

1 participant