Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add `spree upgrade` with per-version upgrade manifests

Damian Legawiec086dc2b6172c
diff --git a/docs/developer/upgrades/5.4-to-5.5.mdx b/docs/developer/upgrades/5.4-to-5.5.mdx
index b800001775..5d5c024e6d 100644
--- a/docs/developer/upgrades/5.4-to-5.5.mdx
+++ b/docs/developer/upgrades/5.4-to-5.5.mdx
@@ -7,23 +7,54 @@ description: Step-by-step guide to upgrading a Spree 5.4 application to Spree 5.
Before proceeding to upgrade, please ensure you're at [Spree 5.4](/developer/upgrades/5.3-to-5.4).
</Info>
-## Upgrade steps
+The upgrade is usually
-### Update gems
+1. **Update the Ruby gems** which power Spree API
+2. **Run database migrations** — to migrate your existing schema to the new version
+3. **Run data backfills** — to move your existing data into the new schema and power new features
+4. **Update Spree SDK NPM package** - to use new API features and avoid breaking changes
+5. Apply optional configuration and review behavior changes — to take advantage of new features and avoid surprises
- ```bash
- bundle update
- ```
+## How to upgrade
-### Fetch and run missing migrations
+For applications created via `create-spree-app` command we greatly recommend using the Spree CLI to perform the upgrade. It provides a guided experience with prompts and handles all three steps for you. If you prefer to run the commands manually or not using docker for local development, you can follow the "Without Spree CLI" path.
- ```bash
- bin/rake spree:install:migrations && bin/rails db:migrate
- ```
+<CodeGroup>
+
+```bash Spree CLI
+spree upgrade
+```
+
+```bash Without Spree CLI
+# cd backend if you're in the monorepo root
+bundle update
+bin/rake spree:install:migrations && bin/rails db:migrate
+bin/rake spree:upgrade
+```
+
+</CodeGroup>
+
+The **Spree CLI** path runs all three commands for you with prompts. Recommended for local development. If you don't have the CLI yet, either install it globally or run it through `npx`:
+
+```bash
+# install once and use `spree …` everywhere
+npm install -g @spree/cli
+
+# or invoke without installing (each command runs through npx)
+npx @spree/cli upgrade
+```
+
+The **Without Spree CLI** path is the bare equivalent. Use this on production: `bundle update` and `db:migrate` are part of your existing deploy pipeline (Heroku release phase, K8s init container, Capistrano hook, Render auto-migrate). Once the 5.5 release is up, run `bin/rake spree:upgrade` from a one-off dyno / job container / `kubectl exec` to perform the data backfills.
+
+Skipping versions and re-running are both safe — `bin/rake spree:upgrade` figures out what still needs to happen and does nothing on data that's already migrated.
+
+## What the upgrade does
+
+This is reference material — what `bin/rake spree:upgrade` (and equivalently `spree upgrade`) actually executes on your data. Skip if you trust the tool; read on if something failed or you're curious.
### Migrate legacy variant-pinned media
-In 5.5 the [product is the default owner of media](/developer/core-concepts/media#product-level-gallery). Existing variant-pinned images keep rendering, but new admin uploads attach to the product. To consolidate both into a single gallery, run:
+In 5.5 the [product is the default owner of media](/developer/core-concepts/media#product-level-gallery). Existing variant-pinned images keep rendering, but new admin uploads attach to the product. To consolidate both into a single gallery, the upgrade runs:
```bash
bin/rails spree:media:migrate_master_images_to_product_media
@@ -45,7 +76,7 @@ bin/rails spree:media:migrate_master_images_to_product_media BATCH_SIZE=1000
Spree 5.5 introduces [Sales Channels](/developer/core-concepts/channels) — a per-store distribution surface (online storefront, POS, marketplace integration, wholesale portal). Products are published to a channel via the new `spree_product_publications` join table, and orders are attributed to a channel via `spree_orders.channel_id`.
-The migrations add a `default` boolean on `spree_channels`, a `store_id` column on `spree_products`, and create the new `spree_product_publications` table — **but they do not seed default channels, attach existing products to a store, or backfill order channels**. That work is done by an idempotent rake task you must run after `db:migrate`:
+The migrations add a `default` boolean on `spree_channels`, a `store_id` column on `spree_products`, and create the new `spree_product_publications` table — **but they do not seed default channels, attach existing products to a store, or backfill order channels**. That work is done by an idempotent rake task:
```bash
bin/rake spree:channels:upgrade
@@ -70,7 +101,7 @@ If you have products attached to multiple stores via the legacy `spree_products_
For single-store deployments this is invisible; you can move on without touching `spree_products_stores` again.
-#### Behavioral changes
+#### Behavioral changes from the Channels upgrade
- Newly-created products in **the dashboard SPA** are auto-published on the store's default channel; the merchant can untick channels post-create via the Publishing card.
- Newly-created products via the **Admin API** are NOT auto-published — the caller must supply `product_publications: [{ channel_id }]` on create or use `POST /api/v3/admin/channels/:id/add_products` afterwards.
@@ -79,6 +110,10 @@ For single-store deployments this is invisible; you can move on without touching
Orders modified after the upgrade auto-set `channel_id` via the model's `before_validation :ensure_channel_presence` callback, so `backfill_order_channel_ids` is only strictly required for orders that aren't touched again post-upgrade — but running it at upgrade time avoids surprises later. The legacy `channel` string column is **kept** on `spree_orders` and ignored by ActiveRecord (`Spree::Order` declares it in `ignored_columns`). It will be dropped in a later Spree release once everyone has had a chance to run the backfill.
+## Required post-upgrade configuration
+
+`bin/rake spree:upgrade` doesn't touch your job-runner config — every app uses a different scheduler, so this one is on you.
+
### Schedule the Stock Reservations expiry job
Spree 5.5 introduces time-limited stock reservations during checkout to prevent two customers from buying the same last unit at the same time. Abandoned checkouts leave behind expired reservation rows, and Spree does **not** auto-schedule the cleanup — your application's job runner must run `Spree::StockReservations::ExpireJob` periodically (every minute is the recommended cadence).
@@ -118,7 +153,11 @@ Rails.application.configure do
end
```
-### (Optional) Tune the reservation TTL
+## Optional tuning
+
+Defaults are sensible for most stores. Reach for these only if you have a specific reason.
+
+### Tune the reservation TTL
The default reservation TTL is **10 minutes**. To override globally:
@@ -135,7 +174,7 @@ store.update!(preferred_stock_reservation_ttl_minutes: 20)
The per-Store value, when set, takes precedence over the global default.
-### (Optional) Disable Stock Reservations
+### Disable Stock Reservations
Stock reservations are enabled by default. To opt out and revert to pre-5.5 behavior (no holds during checkout, Quantifier returns raw `count_on_hand`):
@@ -146,7 +185,7 @@ Spree::Config[:stock_reservations_enabled] = false
The Quantifier short-circuits before any reservation query when this is `false`, so there's no runtime cost and no table growth.
-### (Optional) Opt out of rules-based Order Routing
+### Opt out of rules-based Order Routing
Spree 5.5 introduces [Order Routing](/developer/core-concepts/shipments#order-routing) — a configurable, per-channel pipeline that decides which stock locations fulfill an order. Every store and every channel ships with three default rules (Preferred Location → Minimize Splits → Default Location) that produce sensible behavior out of the box, with no migration work required.
@@ -162,7 +201,9 @@ The Legacy strategy delegates to `Spree::Stock::Coordinator`, which is the exact
`Spree::OrderRouting::Strategy::Legacy` and `Spree::Stock::Coordinator` are slated for removal in Spree 6.0. Use this only as a temporary escape hatch while you evaluate the new Rules strategy. New 5.5+ installations should stay on the default Rules strategy.
</Warning>
-## Behavior changes worth knowing
+## Behavior changes to review
+
+These don't require any rake task — but storefronts, integrations, and merchant-facing dashboards may need code changes to handle them correctly.
### Cart changes during checkout can now fail with insufficient stock
@@ -215,4 +256,4 @@ The default routing strategy (`Spree::OrderRouting::Strategy::Rules`) packs the
For most stores this is invisible: when one location can fulfill the entire cart, that location now wins consistently (instead of depending on database iteration order). When the cart needs to split across locations, the same multi-location split happens — just with the location order driven by rules.
-If you rely on the legacy "every location packed in iteration order, no rule consulted" behavior, see [Opt out of rules-based Order Routing](#optional-opt-out-of-rules-based-order-routing) above.
+If you rely on the legacy "every location packed in iteration order, no rule consulted" behavior, see [Opt out of rules-based Order Routing](#opt-out-of-rules-based-order-routing) above.
diff --git a/packages/cli/.changeset/cli-upgrade-command.md b/packages/cli/.changeset/cli-upgrade-command.md
new file mode 100644
index 0000000000..969dd6979a
--- /dev/null
+++ b/packages/cli/.changeset/cli-upgrade-command.md
@@ -0,0 +1,5 @@
+---
+"@spree/cli": minor
+---
+
+Add `spree upgrade` — sequencer around the dev upgrade flow. Runs `bundle update`, applies pending migrations, then delegates to `bin/rake spree:upgrade` (which executes the version-specific data backfills from a manifest shipped inside `spree_core`). On production, only the rake task runs — your deploy pipeline handles `bundle install` and `db:migrate`. Flags `--plan`, `--step <id>`, `--to <version>`, `--yes` map to env vars (`DRY_RUN`, `STEP`, `TO`) on the rake task so the same arguments work on both surfaces.
diff --git a/packages/cli/src/commands/upgrade.ts b/packages/cli/src/commands/upgrade.ts
new file mode 100644
index 0000000000..b81b33a63a
--- /dev/null
+++ b/packages/cli/src/commands/upgrade.ts
@@ -0,0 +1,137 @@
+import * as p from '@clack/prompts'
+import type { Command } from 'commander'
+import pc from 'picocolors'
+import { detectProject } from '../context.js'
+import { dockerComposeExec } from '../docker.js'
+
+// `spree upgrade` is a dev-friendly sequencer around the real upgrade flow:
+//
+// 1. bundle update (universal — bumps spree_core etc.)
+// 2. db:migrate (universal — applies the new gem's migrations)
+// 3. spree:upgrade (version-specific — runs the rake-only manifest)
+//
+// On production, step 3 is what your deploy pipeline runs after `bundle
+// install` + `db:migrate` happen there. Steps 1 and 2 are handled by your
+// platform (Heroku release phase, K8s init container, Render auto-migrate,
+// Capistrano deploy hook), not by this CLI.
+//
+// Local dev: this command runs all three for you. On a clean stack the
+// total time is dominated by `bundle update` (network + native ext build).
+//
+// Flags map to env vars on the inner rake task so the same args work in
+// both surfaces:
+// --plan DRY_RUN=1 (also skips steps 1 + 2)
+// --step <id> STEP=<id>
+// --to <version> TO=<version>
+// --yes no flag — skips the per-step prompt
+//
+// What this CLI deliberately does NOT do: schedule cron jobs, review
+// breaking changes, tune reservation TTLs. Those are in
+// docs/developer/upgrades/<v>.mdx and the manifest's `notes` text; we
+// print the docs URL at the end so the operator knows where to look.
+export function registerUpgradeCommand(program: Command): void {
+ program
+ .command('upgrade')
+ .description('Walk through a Spree version upgrade (bundle + migrate + spree:upgrade)')
+ .option('--plan', 'print the plan via spree:upgrade DRY_RUN=1; skip bundle + migrate')
+ .option('--step <id>', 'run a single rake step by id (skips bundle + migrate)')
+ .option('--to <version>', 'explicit target version (auto-detected from installed gem otherwise)')
+ .option('--yes', 'skip prompts on automated steps')
+ .action(
+ async (flags: {
+ plan?: boolean
+ step?: string
+ to?: string
+ yes?: boolean
+ }) => {
+ const ctx = detectProject()
+
+ // --plan and --step both opt out of the universal pre-steps:
+ // --plan: we're not running anything anyway.
+ // --step: the operator is retrying one rake step after a fix;
+ // bundle/migrate already happened in the original run.
+ const skipUniversal = Boolean(flags.plan || flags.step)
+
+ if (!skipUniversal) {
+ await runBundleUpdate(ctx.projectDir, flags)
+ await runMigrate(ctx.projectDir, flags)
+ }
+
+ await runRakeUpgrade(ctx.projectDir, flags)
+
+ // Closing reminder: the manifest only covers rake-runnable steps.
+ // Anything human (cron scheduling, breaking-change review) is in
+ // the upgrade doc — point there so the operator doesn't forget.
+ printPostUpgradeReminder()
+ },
+ )
+}
+
+async function runBundleUpdate(
+ projectDir: string,
+ flags: { yes?: boolean },
+): Promise<void> {
+ if (!flags.yes) {
+ const confirmed = await p.confirm({
+ message: 'Run `bundle update` to bump Spree gems?',
+ initialValue: true,
+ })
+ if (p.isCancel(confirmed) || !confirmed) {
+ p.cancel('Upgrade aborted.')
+ process.exit(0)
+ }
+ }
+ p.log.step(pc.bold('bundle update'))
+ await dockerComposeExec(['bundle', 'update'], projectDir)
+}
+
+async function runMigrate(projectDir: string, flags: { yes?: boolean }): Promise<void> {
+ if (!flags.yes) {
+ const confirmed = await p.confirm({
+ message: 'Install + run pending migrations?',
+ initialValue: true,
+ })
+ if (p.isCancel(confirmed) || !confirmed) {
+ p.cancel('Upgrade aborted.')
+ process.exit(0)
+ }
+ }
+ p.log.step(pc.bold('spree:install:migrations + db:migrate'))
+ // Compound rails invocation matches the canonical upgrade doc.
+ await dockerComposeExec(
+ ['bin/rails', 'spree:install:migrations', 'db:migrate'],
+ projectDir,
+ )
+}
+
+async function runRakeUpgrade(
+ projectDir: string,
+ flags: { plan?: boolean; step?: string; to?: string },
+): Promise<void> {
+ // Flags become env vars on the rake side. This is the contract that
+ // keeps prod (operator typing `STEP=channels rake spree:upgrade`) and
+ // dev (this CLI) using the same execution path.
+ const env: Record<string, string> = {}
+ if (flags.plan) env.DRY_RUN = '1'
+ if (flags.step) env.STEP = flags.step
+ if (flags.to) env.TO = flags.to
+
+ p.log.step(pc.bold('spree:upgrade'))
+ await dockerComposeExec(['bin/rake', 'spree:upgrade'], projectDir, { env })
+}
+
+function printPostUpgradeReminder(): void {
+ p.note(
+ [
+ `The manifest only ran ${pc.bold('rake-automatable')} steps.`,
+ '',
+ 'Don\'t forget the manual parts from the upgrade doc:',
+ ` ${pc.dim('- Schedule Spree::StockReservations::ExpireJob (cron)')}`,
+ ` ${pc.dim('- Review behavior changes (cart, availability, payment-method types)')}`,
+ ` ${pc.dim('- Audit custom decorators against renamed APIs')}`,
+ '',
+ `Full checklist: ${pc.cyan('https://spreecommerce.org/docs/developer/upgrades')}`,
+ ].join('\n'),
+ 'Next steps',
+ )
+}
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index 66f8c6ae45..feb9922444 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -21,6 +21,7 @@ import { registerSeedCommand } from './commands/seed.js'
import { registerStopCommand } from './commands/stop.js'
import { registerTaskCommand } from './commands/task.js'
import { registerUpdateCommand } from './commands/update.js'
+import { registerUpgradeCommand } from './commands/upgrade.js'
import { registerUserCommand } from './commands/user.js'
const program = new Command()
@@ -46,6 +47,7 @@ registerGenerateCommand(program)
registerMigrateCommand(program)
registerDbCommand(program)
registerRoutesCommand(program)
+registerUpgradeCommand(program)
// Run things inside the container
registerExecCommand(program)
diff --git a/spree/core/lib/spree/upgrades/5_4_to_5_5/manifest.yml b/spree/core/lib/spree/upgrades/5_4_to_5_5/manifest.yml
new file mode 100644
index 0000000000..0459f88a4f
--- /dev/null
+++ b/spree/core/lib/spree/upgrades/5_4_to_5_5/manifest.yml
@@ -0,0 +1,43 @@
+# Spree 5.4 → 5.5 upgrade manifest.
+#
+# Lists ONLY the version-specific rake tasks that perform data backfills.
+# Universal upgrade steps (bundle update, db:migrate, scheduling cron jobs,
+# reviewing breaking changes) are NOT in this file:
+#
+# - `bundle update` + `db:migrate` are handled by your deploy pipeline
+# (Heroku release phase, K8s init container, Render auto-migrate,
+# Capistrano deploy hook, etc.) and by the @spree/cli's `spree upgrade`
+# wrapper for local development.
+# - Cron scheduling, optional tunings, and human-readable behavior changes
+# live in the upgrade doc at docs/developer/upgrades/5.4-to-5.5.mdx.
+#
+# This manifest is the machine-runnable shape — what `bin/rake spree:upgrade`
+# (in production) and `spree upgrade` (in dev) execute. Every step must be a
+# rake task and must be idempotent. Re-running the full manifest is safe.
+---
+from: "5.4"
+to: "5.5"
+docs: "https://spreecommerce.org/docs/developer/upgrades/5.4-to-5.5"
+
+steps:
+ - id: media
+ name: "Migrate legacy variant-pinned images to product-level media"
+ task: "spree:media:migrate_master_images_to_product_media"
+ notes: |
+ Enqueues one `Spree::Media::MigrateProductAssetsJob` per product onto
+ the `images` queue — confirm your job runner is processing that queue.
+ Storefront keeps working while jobs drain (old assets stay variant-pinned
+ until each job finishes). For large catalogs, tune with BATCH_SIZE=1000.
+
+ - id: channels
+ name: "Run the Channels upgrade (creates default channels, publications, order channel ids)"
+ task: "spree:channels:upgrade"
+ notes: |
+ Aggregator that runs four sub-tasks in order:
+ 1. spree:channels:create_defaults
+ 2. spree:upgrade:populate_publications
+ 3. spree:channels:backfill_order_channel_ids
+ 4. spree:channels:backfill_product_publication_dates
+ Until this runs, every product has store_id IS NULL and is invisible
+ to Product.for_store — admin lists, storefront catalog, and search
+ indexer all return empty.
diff --git a/spree/core/lib/tasks/upgrade.rake b/spree/core/lib/tasks/upgrade.rake
new file mode 100644
index 0000000000..919cf14f2e
--- /dev/null
+++ b/spree/core/lib/tasks/upgrade.rake
@@ -0,0 +1,185 @@
+# frozen_string_literal: true
+
+# spree:upgrade — runs the data-backfill rake tasks shipped with the
+# currently-installed spree_core. Intended to run on production (or any
+# environment) after `bundle update` + `db:migrate` have already happened
+# in your deploy pipeline.
+#
+# Walks EVERY upgrade manifest whose `to` is ≤ the installed minor version,
+# in ascending order. So an app that's been on 5.3 and jumps straight to
+# 5.5 still gets the 5.3→5.4 data backfills before the 5.4→5.5 ones.
+# Every step in every manifest is required to be idempotent — re-running
+# the task on an already-upgraded app is a safe no-op.
+#
+# Usage:
+# bundle exec rake spree:upgrade # walk all eligible manifests
+# bundle exec rake spree:upgrade DRY_RUN=1 # print plan, run nothing
+# bundle exec rake spree:upgrade STEP=channels # run one step by id (any manifest)
+# bundle exec rake spree:upgrade TO=5.4 # cap the walk at this version
+#
+# Manifests live alongside this file at lib/spree/upgrades/<from>_to_<to>/
+# manifest.yml and ship inside the spree_core gem.
+
+require 'yaml'
+
+namespace :spree do
+ desc 'Run the post-deploy upgrade tasks for the installed Spree version'
+ task upgrade: :environment do
+ Spree::Upgrade::Runner.new(
+ target_version: ENV['TO'],
+ step_id: ENV['STEP'],
+ dry_run: ENV['DRY_RUN'] == '1'
+ ).call
+ end
+end
+
+module Spree
+ module Upgrade
+ # Two-segment "5.5" form of the installed Spree version.
+ def self.installed_minor_version
+ Spree.version.split('.').first(2).join('.')
+ end
+
+ # Root directory containing N_M_to_O_P/manifest.yml files inside
+ # the spree_core gem.
+ def self.manifests_root
+ File.expand_path('../spree/upgrades', __dir__)
+ end
+
+ # All available manifest directories, parsed into { from:, to:, dir: }.
+ # Sorted by `to` ascending, with `from` as a tiebreaker (smallest first)
+ # for the rare case where two manifests share a `to` boundary.
+ def self.available_manifests
+ Dir.glob(File.join(manifests_root, '*_to_*')).filter_map do |dir|
+ name = File.basename(dir)
+ match = name.match(/\A([\d_]+)_to_([\d_]+)\z/)
+ next unless match
+
+ { from: match[1].tr('_', '.'), to: match[2].tr('_', '.'), dir: dir }
+ end.sort_by { |m| version_parts(m[:to]) + version_parts(m[:from]) }
+ end
+
+ def self.version_parts(v)
+ v.split('.').map { |s| Integer(s, 10) rescue 0 }
+ end
+
+ # Compare two dotted-version strings (returns -1, 0, +1).
+ def self.compare(a, b)
+ version_parts(a) <=> version_parts(b)
+ end
+
+ # The runner is a class (not a method) so individual concerns (selection,
+ # rendering, invocation) stay separable and the plan can be inspected
+ # without execution.
+ class Runner
+ attr_reader :target_version, :step_id, :dry_run
+
+ def initialize(target_version: nil, step_id: nil, dry_run: false)
+ @target_version = target_version || Spree::Upgrade.installed_minor_version
+ @step_id = step_id
+ @dry_run = dry_run
+ end
+
+ def call
+ manifests = eligible_manifests
+
+ if manifests.empty?
+ puts " No upgrade manifests apply to Spree #{target_version} (installed: #{Spree::Upgrade.installed_minor_version})."
+ return
+ end
+
+ if step_id
+ run_single_step(manifests)
+ else
+ run_full_walk(manifests)
+ end
+ end
+
+ private
+
+ # Every manifest whose `to` is ≤ target_version, in walk order.
+ def eligible_manifests
+ Spree::Upgrade.available_manifests
+ .select { |m| Spree::Upgrade.compare(m[:to], target_version) <= 0 }
+ .map { |entry| load_manifest_yaml(entry) }
+ end
+
+ def load_manifest_yaml(entry)
+ YAML.safe_load_file(File.join(entry[:dir], 'manifest.yml'))
+ end
+
+ def run_full_walk(manifests)
+ total_steps = manifests.sum { |m| m['steps'].size }
+ puts
+ puts " Walking #{manifests.size} manifest(s), #{total_steps} step(s) total. Target: Spree #{target_version}."
+
+ manifests.each do |manifest|
+ print_manifest_header(manifest)
+ manifest['steps'].each_with_index do |step, i|
+ print_step(step, i + 1, manifest['steps'].size)
+ invoke(step) unless dry_run
+ end
+ end
+
+ puts
+ puts dry_run ? ' (dry run — nothing executed)' : ' Upgrade tasks complete.'
+ end
+
+ # STEP=<id> looks across every eligible manifest; we need exactly one
+ # match. Multiple matches are likely a manifest bug (two manifests
+ # referencing the same step id) but we surface it rather than picking
+ # silently.
+ def run_single_step(manifests)
+ matches = manifests.flat_map do |manifest|
+ manifest['steps'].select { |s| s['id'] == step_id }.map { |s| [manifest, s] }
+ end
+
+ if matches.empty?
+ available = manifests.flat_map { |m| m['steps'] }.map { |s| s['id'] }.uniq.join(', ')
+ abort " No step with id '#{step_id}' in any eligible manifest. Available: #{available}"
+ elsif matches.size > 1
+ locations = matches.map { |m, _| "#{m['from']} → #{m['to']}" }.join(', ')
+ abort " Step id '#{step_id}' is ambiguous — defined in: #{locations}. Pass TO=<version> to narrow."
+ end
+
+ manifest, step = matches.first
+ print_manifest_header(manifest)
+ print_step(step, 1, 1)
+ invoke(step) unless dry_run
+
+ puts
+ puts dry_run ? ' (dry run — nothing executed)' : " Step '#{step_id}' complete."
+ end
+
+ def print_manifest_header(manifest)
+ puts
+ puts " ── Spree #{manifest['from']} → #{manifest['to']} ──"
+ puts " Docs: #{manifest['docs']}" if manifest['docs']
+ end
+
+ def print_step(step, index, total)
+ puts
+ puts " Step #{index}/#{total} [#{step['id']}]"
+ puts " #{step['name']}"
+ puts " > bin/rake #{step['task']}"
+ return unless step['notes']
+
+ step['notes'].each_line { |line| puts " #{line.chomp}" }
+ end
+
+ def invoke(step)
+ task = step.fetch('task')
+ puts " Running #{task}..."
+
+ # Rake caches invoked tasks in-process; explicit reenable lets a
+ # single `rake spree:upgrade` run re-invoke aggregators that share
+ # subtasks across multiple manifests (e.g. two manifests both
+ # depending on `spree:install:migrations` would otherwise only
+ # invoke it once).
+ rake_task = Rake::Task[task]
+ rake_task.reenable
+ rake_task.invoke
+ end
+ end
+ end
+end