solidus_dev_support, a gem whose job is to make it a no-brainer to develop Solidus extensions. The gem provides static and runtime utilities that help you create a new extension, make it compatible with different Solidus versions, release it and maintain it over time.
solidus extensioncommand. Solidus extensions are generally named
solidus_, and then the name of the feature or integration they provide, so we'll follow this convention for our Acme Fulfillment extension:
solidus_acme_fulfillmentdirectory in the current path. This directory will contain a lot of boilerplate that is required to make your extension play nice with Solidus and Rails conventions.
solidus_dev_supporttries to be as smart as possible and use some sensible defaults for your extension, but we'll still need to adjust some values before we can proceed.
solidus_acme_fulfillment.gemspecin your favorite text editor, and change the following lines to configure a description for your extension:
HTTPmodule, but its API is kind of cumbersome and not really fun to work with. Instead, we'll go with the popular
httpartygem. In order to do that, let's add the dependency to our gemspec:
httpartyis also installed by any apps that install our extension. We can now reinstall the bundle to get the new gem:
httpartygem in our extension's main file, since gem dependencies are not autoloaded by Bundler when initializing the main app:
httpartyeverywhere in our extension's code!
solidus_dev_supportships with a sample configuration file where you can add any options that you want the user to be able to configure. The skeleton also contains an initializer which will be copied to the main app when the extension is installed, so that the user doesn't have to write the configuration code manually.
lib/solidus_acme_fulfillment/configuration.rbfile as follows:
config/initializers/solidus_acme_fulfillment.rbwhich will contain our sample configuration.
spree_orderstable, so let's first write a migration to create it:
order_finalizedevent and, when it's fired, it calls the Acme Fulfillment API with the configured API key and the serialized order information. It then parses the API response and sets the
acme_fulfillment_shipment_idcolumn on the order to the ID returned by the fulfillment partner's API.
solidus_dev_supportprovides a Rake task we can run to generate a "sandbox app", i.e. a barebones Rails + Solidus application with our extension already installed and configured. The sandbox app is extremely useful in extension development, and it's important to learn to make the best of it.
sandboxdirectory in the root of your extension. This contains your new shiny sandbox app. Your extension has already been installed and configured inside the app: try looking for the
solidus_dev_supportalso allows you to run commands in your sandbox app from the root of your extension, just as you would do with a regular Rails application. Try spinning up a Rails server:
solidus_dev_supportis configured to release your gem on RubyGems. If you're using a different gem server, they should provide instructions on how to properly configure your gemspec.
@solidusio/extensionsCircleCI orb. The orb will automatically test your Solidus extension against the right Solidus versions, without the need for you to update the versions list manually. The orb will even periodically test your extension against the latest
masterbranch of Solidus, so that you know whether your extension is compatible with the upcoming version of Solidus!
masterand in other branches against the currently supported Solidus versions, as well as against the latest
master, in order to ensure the correctness of any code changes you push to the extension.
masterweekly against the currently supported Solidus versions, as well as against the latest
master, in order to ensure your extension's code is compatible with the upcoming Solidus release.