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

Update woo-shipping #109

Merged
merged 8 commits into from
Feb 7, 2025
Merged

Update woo-shipping #109

merged 8 commits into from
Feb 7, 2025

Conversation

bph
Copy link
Collaborator

@bph bph commented Feb 3, 2025

Fixes #102

  • use shorthand for .org plugin
  • use new installPlugin api
  • replace reference to personal GitHub repo
  • moved siteOptions to the end and use shorthand

Copy link

github-actions bot commented Feb 3, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@bph
Copy link
Collaborator Author

bph commented Feb 3, 2025

Error Message

[03-Feb-2025 15:07:50 UTC] JavaScript Error: Error: Could not download "https://raw.githubusercontent.com/wordpress/blueprints/woo-shipping/blueprints/woo-shipping/sample_products.xml".

Corrected to be https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/woo-shipping/sample_products.xml

@bph
Copy link
Collaborator Author

bph commented Feb 3, 2025

The step

"step": "installPlugin",
			"pluginData": {
			  "resource": "literal:directory",
			  "name": "woo-shipping-method",
			  "files": {
				"woo-shipping-method.php": {
				  "resource": "url",
				  "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/woo-shipping/woo-shipping-method/woo-shipping-method.php"
				}
			  }
			},
			"options": {
			  "activate": true
			}

Ran into the following error message: "
Error when executing the blueprint step #4 ({"step":"installPlugin","pluginData":{"resource":"literal:directory","name":"woo-shipping-method","files":{"woo-shipping-method.php":{"resource":"url","url":"https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/woo-shipping/woo-shipping-method/woo-shipping-method.php"}}},"options":{"activate":true}}) : Plugin /wordpress/wp-content/plugins/woo-shipping-method could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details.

Replacing it with a writeFiles step

{
  "step": "writeFiles",
  "writeToPath": "/wordpress/wp-content/plugins/woo-shipping-method",
  "filesTree": {
    "resource": "literal:directory",
    "name": "woo-shipping-method",
    "files": {
      "woo-shipping-method.php": {
        "resource": "url",
        "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/woo-shipping/woo-shipping-method/woo-shipping-method.php"
      }
    }
  }
},
{
  "step": "activatePlugin",
  "pluginPath": "woo-shipping-method/woo-shipping-method.php"
}

@bph
Copy link
Collaborator Author

bph commented Feb 3, 2025

These are all the error messages and warnings.

[03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22
[03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22

See more [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:13 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Undefined variable $term in /internal/eval.php on line 22 [03-Feb-2025 15:34:14 UTC] PHP Warning: Trying to access array offset on value of type null in /internal/eval.php on line 22
[03-Feb-2025 15:34:14 UTC] JavaScript Warn: Plugin woo-shipping-method/woo-shipping-method.php activation printed the following bytes: The plugin does not have a valid header. [03-Feb-2025 15:34:15 UTC] JavaScript Error: Plugin woo-shipping-method/woo-shipping-method.php could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details. Error: Plugin woo-shipping-method/woo-shipping-method.php could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details. at Object.En [as activatePlugin] (https://playground.wordpress.net/assets/index-7eeeccac.js:72:97) at async p (https://playground.wordpress.net/assets/index-7eeeccac.js:905:147772) at async Object.run (https://playground.wordpress.net/assets/index-7eeeccac.js:905:146668) at async Vu (https://playground.wordpress.net/assets/index-7eeeccac.js:905:148232) at async nc (https://playground.wordpress.net/assets/index-7eeeccac.js:905:149113) at async https://playground.wordpress.net/assets/main-eaa04db9.js:151:2437 [03-Feb-2025 15:34:15 UTC] JavaScript Error: Error when executing the blueprint step #5 ({"step":"activatePlugin","pluginPath":"woo-shipping-method/woo-shipping-method.php"}) : Plugin woo-shipping-method/woo-shipping-method.php could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details. Error: Error when executing the blueprint step #5 ({"step":"activatePlugin","pluginPath":"woo-shipping-method/woo-shipping-method.php"}) : Plugin woo-shipping-method/woo-shipping-method.php could not be activated – WordPress exited with no error. Sometimes, when $_SERVER or site options are not configured correctly, WordPress exits early with a 301 redirect. Inspect the "debug" logs in the console for more details. at Object.run (https://playground.wordpress.net/assets/index-7eeeccac.js:905:146713) at async Vu (https://playground.wordpress.net/assets/index-7eeeccac.js:905:148232) at async nc (https://playground.wordpress.net/assets/index-7eeeccac.js:905:149113) at async https://playground.wordpress.net/assets/main-eaa04db9.js:151:2437

From the Browser Console:
Screenshot 2025-02-03 at 16 37 32

Not quite sure how to solve things....
@adamziel I must be missing something.

@juanmaguitar
Copy link
Contributor

juanmaguitar commented Feb 3, 2025

@bph I think the issue is in the files structure under filesTree when "resource": "literal:directory". When "resource": "literal:directory" the files property under filesTree expects a direct file tree structure

About Directory References

Right now there are only two types of *Directory*Reference resources: literal:directory and git:directory

export type GitDirectoryReference = {
	/** Identifies the file resource as a git directory */
	resource: 'git:directory';
	/** The URL of the git repository */
	url: string;
	/** The branch of the git repository */
	ref: string;
	/** The path to the directory in the git repository */
	path: string;
};
export interface Directory {
	files: FileTree;
	name: string;
}
export type DirectoryLiteralReference = Directory & {
	/** Identifies the file resource as a git directory */
	resource: 'literal:directory';
};

An example of using the writeFiles step in combination with "resource": "git:directory" can be seen here

{
			"step": "writeFiles",
			"writeToPath": "/wordpress/wp-content/plugins/slotfill-2fb190",
			"filesTree": {
				"resource": "git:directory",
				"url": "https://github.com/WordPress/block-development-examples",
				"ref": "HEAD",
				"path": "plugins/slotfill-2fb190"
			}
		},

This won't work:

"filesTree": {
  "resource": "literal:directory",
  "name": "woo-shipping-method",
  "files": {
    "woo-shipping-method.php": {
      "resource": "url",
      "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/woo-shipping/woo-shipping-method/woo-shipping-method.php"
    }
  }
}

as what this code is doing is generating the following structure of files (that cannot be activated as a plugin):

- /wordpress/wp-content/plugins/woo-shipping-method/woo-shipping-method/woo-shipping-method.php/resource
- /wordpress/wp-content/plugins/woo-shipping-method/woo-shipping-method/woo-shipping-method.php/url

Tip

A good tip to debug blueprints is to check the FileSystem after the launch with the blueprint to check the final files being created. I usually just add "plugins" : ["wpide"] for this.

instead, filesTree should be something like:

{
      "step": "writeFiles",
      "writeToPath": "/wordpress/wp-content/plugins/woo-shipping-method",
      "filesTree": {
        "resource": "literal:directory",
        "name": "woo-shipping-method",
        "files": {
          "woo-shipping-method.php": "<?php\n// Plugin contents will go here\n"
        }
      }
    }

NOTE: I'm not sure about the real purpose of "resource": "literal:directory", here (as it would also work without it)

The writeFiles step by default expects a direct FileTree interface where:

  • Keys are file/directory names
  • Values are either:
    • Strings (for file contents)
    • Objects (for subdirectories)

For example:

{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "login": true,
  "steps": [

    {
      "step": "writeFiles",
      "writeToPath": "/wordpress/wp-content/plugins/woo-shipping-method",
      "filesTree": {
        "name": "woo-shipping-method",
        "files": {
          "plugin.php": "<?php\n/*\nPlugin Name: My Plugin\n*/",
          "readme.txt": "=== My Plugin ===\nDescription: A simple plugin",
          "includes": {
            "class-main.php": "<?php\nclass Main_Class {}",
            "functions.php": "<?php\nfunction my_plugin_init() {}"
          },
          "assets": {
            "css": {
              "style.css": "body { background: #fff; }",
              "admin.css": "/* Admin styles */"
            },
            "js": {
              "script.js": "console.log('Hello');",
              "admin.js": "// Admin JavaScript"
            }
          }
        }
      }
    }
  ]
}

@bph
Copy link
Collaborator Author

bph commented Feb 4, 2025

Thank you so much @juanmaguitar for walking me through this.

NOTE: I'm not sure about the real purpose of "resource": "literal:directory", here (as it would also work without it)>
A blueprint without the resource option will run into an error.

Screenshot 2025-02-03 at 15 21 28

It seems for this particular use case, the earlier combination pf mkdir + writeFile + activatePlugin steps are still the best way to implement it.

{
			"step": "mkdir",
			"path": "/wordpress/wp-content/plugins/woo-shipping-method"
		},
		{
			"step": "writeFile",
			"path": "/wordpress/wp-content/plugins/woo-shipping-method/woo-shipping-method.php",
			"data": {
				"resource": "url",
				"url": "https://raw.githubusercontent.com/calvinrodrigues500/blueprints/woo-shipping/blueprints/woo-shipping/woo-shipping-method/woo-shipping-method.php"
			}
		},
		{
			"step": "activatePlugin",
			"pluginName": "woo-shipping-method",
			"pluginPath": "woo-shipping-method/woo-shipping-method.php"
		}

As the woo-shipping-method.php file is also available on the blueprints repo, I would only change the URL to "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/woo-shipping/woo-shipping-method/woo-shipping-method.php"

@bph
Copy link
Collaborator Author

bph commented Feb 4, 2025

Tested it again and now it works.

@adamziel
Copy link
Contributor

adamziel commented Feb 4, 2025

NOTE: I'm not sure about the real purpose of "resource": "literal:directory", here (as it would also work without it)

Oh! This is unexpected and seems like a bug. Would you please open an issue to track this?

@bph
Copy link
Collaborator Author

bph commented Feb 4, 2025

@bph bph merged commit 2ebde12 into trunk Feb 7, 2025
2 checks passed
@bph bph deleted the update-woo-shipping branch February 7, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Update Woo-shipping to use Install plugin with plugindata literal:directory
4 participants