🖨 Command line tool to make life a tiny bit easier while working with Magento
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.babelrc
.eslintrc.js
.gitignore
.npmignore
README.md
package.json
yarn.lock

README.md

copyplate

For when you get fed up of working out the app/design location of a vendor file in Magento.

When given a valid path to a module file in the vendor directory, it will create the correct override file in app/design. See the test/ directory for examples.

Using locally

Clone the repo and from the room run npm i -g - now you can run this from anywhere on your machine!

Vendor is currently Vendor and theme is default, so override these as command line arguments - vendor name first and theme name second, e.g.

copyplate vendor/magento/module-wishlist/view/frontend/web/js/wtf.js MyVendor myTheme
# creates app/design/frontend/MyVendor/myTheme/Magento_Wishlist/web/js/wtf.js

Testing locally

npm run babel
mkdir -p vendor/magento/module-wishlist/view/frontend/web/js
echo FU >> vendor/magento/module-wishlist/view/frontend/web/js/wtf.js
# If installed globally with npm i -g:
copyplate vendor/magento/module-wishlist/view/frontend/web/js/wtf.js
# Otherwise
node dist/copyplate.js vendor/magento/module-wishlist/view/frontend/web/js/wtf.js MyVendor myTheme
less app/design/frontend/MyVendor/myTheme/Magento_Wishlist/web/js/wtf.js

Developing

Compile with babel src/ -d dist/.

Run tests with npm t.

Run as shell script with the hashbang at the top #!/usr/bin/env node, make sure the file is executable (chmod u+x myscript.js) and then run with .dist/copyplate.js.

Improvements

  • Make vendor name customisable
  • Make theme name customisable (write tests)
  • More tests for bad input
  • Be able to copy to app/code: only does app/design for now: set --flag for this
  • Handle absolute paths: only handles vendor/... for now
  • Change theme and vendor to --flags
  • Write better log messages - print out path of new file on success