Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Changes required to be compatible with the pivot extensible discount scripts #1678

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
From version 2.6.0, the sections in this file adhere to the [keep a changelog](https://keepachangelog.com/en/1.0.0/) specification.
## [Unreleased]

### Added
* [#1609](https://github.com/Shopify/shopify-cli/pull/1609): Add `--bind=HOST` option to `shopify theme serve`.

### Fixed
* [#1678](https://github.com/Shopify/shopify-cli/pull/1678): Fix migrator's incompatibility with Ruby 2.5.
### Changed
* [#1678](https://github.com/Shopify/shopify-cli/pull/1678): Change the `@shopify/scripts-checkout-apis-temp` package name to `@shopify/scripts-discount-apis`.
## Version 2.6.5
### Fixed
* [#1661](https://github.com/Shopify/shopify-cli/pull/1661): Handle npm list non-zero exit status when pushing scripts
Expand Down
2 changes: 1 addition & 1 deletion lib/project_types/script/config/extension_points.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ discount_types:
libraries:
typescript:
beta: true
package: "@shopify/scripts-checkout-apis-temp"
package: "@shopify/scripts-discount-apis"
repo: "https://github.com/Shopify/scripts-apis-examples"
20 changes: 9 additions & 11 deletions lib/shopify_cli/migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ def self.migrate(
migrations_directory: File.expand_path("migrator/migrations", __dir__)
)
baseline_date = last_migration_date
unless baseline_date.nil?
migrations = migrations(migrations_directory: migrations_directory)
.select { |m|
m.date > baseline_date.to_i
}
.each { |m| m.run }
unless baseline_date.nil?
migrations(migrations_directory: migrations_directory)
.select do |m|
m.date > baseline_date.to_i
end
.each(&:run)
end

store_last_migration_date
end

private

def self.store_last_migration_date
ShopifyCLI::DB.set(ShopifyCLI::Constants::StoreKeys::LAST_MIGRATION_DATE => Time.now.to_i)
end

def self.last_migration_date
ShopifyCLI::DB.get(ShopifyCLI::Constants::StoreKeys::LAST_MIGRATION_DATE)
end
Expand All @@ -35,7 +33,7 @@ def self.migrations(migrations_directory:)
file_name = File.basename(file_path).gsub(".rb", "")
file_name_components = file_name.split("_")
date_timestamp = file_name_components[0].to_i
migration_name = file_name_components[1...].join("_")
migration_name = file_name_components.drop(1).join("_")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[1,2,3].drop(1) == [1,2,3][1...]


Migrator::Migration.new(
name: migration_name,
Expand All @@ -45,4 +43,4 @@ def self.migrations(migrations_directory:)
end
end
end
end
end