Sha256: a8b007a6214ca4ec7d7b125ea93cd398895dca8d5fb0b2e6036237844895cf2e
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module Script module Layers module Infrastructure class ConfigUiRepository include SmartProperties property! :ctx, accepts: ShopifyCli::Context def create_config_ui(filename, content) File.write(filename, content) Domain::ConfigUi.new( filename: filename, content: content, ) end def get_config_ui(filename) return nil unless filename path = File.join(ctx.root, filename) raise Domain::Errors::MissingSpecifiedConfigUiDefinitionError, filename unless File.exist?(path) content = File.read(path) raise Domain::Errors::InvalidConfigUiDefinitionError, filename unless valid_config_ui?(content) Domain::ConfigUi.new( filename: filename, content: content, ) end private def valid_config_ui?(raw_yaml) require "yaml" # takes 20ms, so deferred as late as possible. YAML.safe_load(raw_yaml) true rescue Psych::SyntaxError false end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shopify-cli-1.8.0 | lib/project_types/script/layers/infrastructure/config_ui_repository.rb |
shopify-cli-1.7.1 | lib/project_types/script/layers/infrastructure/config_ui_repository.rb |