wecodemore / wpstarter

Easily bootstrap whole site Composer packages for WordPress.
https://wecodemore.github.io/wpstarter/
MIT License
244 stars 34 forks source link

WPStarter v3 scripts not executing #97

Closed saas786 closed 1 year ago

saas786 commented 5 years ago

Hi there,

I am trying to execute WPStarter script to remove the wp-content dir, but it doens't work.

I have setup a test repo here:

https://github.com/saas786/wpstarter-3-test/blob/wps-scripts/wpstarter.json

which just echo some test string as per: https://github.com/wecodemore/wpstarter/blob/dev/docs/08-Custom-Steps-Development.md#making-steps-classes-autoloadable

but it doesn't work, gets executed.

Can you please point me in right direction, so I could execute WPStarter scripts.

also

can i use same step for multiple scripts like

https://github.com/saas786/wpstarter-3-test/blob/wps-scripts/wpstarter.json#L11

        "pre-wpstarter": "MyCompany\\MyProject\\sayHelloBeforeStarting",
        "pre-wpstarter": "MyCompany\\MyProject\\doSomethingSpecial"

Thanks

gmazzap commented 5 years ago

Hi @saas786 did you find a solution?

saas786 commented 5 years ago

Hi @gmazzap,

I didn't found a solution yet. I thought it might be doing something incorrect that's why author didn't respond. So closed it.

If you are willing to help, I can provide you with feedback.

Configuration contains one invalid step setting and it
  will be ignored.

When I try to debug it, it seems like my extension / package code is not loading.

Have you created any sample package on github which I could load as a test? As mine doesn't seem to work, maybe I have some incorrect setting.

I have tried both

'autoload' & 'wpstarter-autoload'

I have used relative path to project root, and also loaded it as composer package with type

"type": "wpstarter-extension"

Thanks

gmazzap commented 5 years ago

I thought it might be doing something incorrect that's why author didn't respond.

I'm the author and I did not respond because I've been on vacation in the last 2 weeks and very busy the days before leaving :)

I will have a look as soon as I can, being back just today after two weeks there's a big pile of things on my desk right now.

saas786 commented 5 years ago

:) Nice to meet you.

Hopefully you enjoyed your time off.

You must have, nothing urgent, let me know if I can help. Will be happy to help.

gmazzap commented 1 year ago

Finally got at the bottom of this.

The documentation was wrong.

I was documenting:

   "scripts": {
        "pre-wpstarter": "MyCompany\\MyProject\\sayHelloBeforeStarting"
    }

But in reality vlaues were supposed to be an array, like this:

   "scripts": {
        "pre-wpstarter": [ "MyCompany\\MyProject\\sayHelloBeforeStarting" ]
    }

That is why you got the "invalid script" debug message.

And that also answer the question "Can I have multiple scripts for the same event?" Yes, you can, using an array.

--

With 6977b71 I added support for a single script to be provied as string, as it was documented.

Moreover, I fixed the usage in documentation of a Io class private method.

Finally, I also made WP Starter less lenient about invalid scripts: if an invalid script is added, it now fails WP Starter execution with a more telling message.

Thanks for reporting, and for the long wait.