From 845a037b9bff0c1903d75be1d7e81a675a1a63ee Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Fri, 15 Nov 2024 09:59:37 +0100 Subject: [PATCH 01/10] Add schema validation for dip.yml configuration --- README.md | 26 +++ dip.gemspec | 3 +- examples/dip.yml | 133 +++++++++++++ lib/dip/cli.rb | 11 +- lib/dip/config.rb | 27 ++- schema.json | 229 ++++++++++++++++++++++ spec/fixtures/invalid-with-schema/dip.yml | 9 + spec/fixtures/no-schema/dip.yml | 9 + spec/lib/dip/config_spec.rb | 32 +++ 9 files changed, 475 insertions(+), 4 deletions(-) create mode 100644 examples/dip.yml create mode 100644 schema.json create mode 100644 spec/fixtures/invalid-with-schema/dip.yml create mode 100644 spec/fixtures/no-schema/dip.yml diff --git a/README.md b/README.md index f9e2713..3f93540 100644 --- a/README.md +++ b/README.md @@ -472,6 +472,32 @@ services: user: "1000:1000" ``` +### dip validate + +Validates your dip.yml configuration against the JSON schema. The schema validation helps ensure your configuration is correct and follows the expected format. + +```sh +dip validate +``` + +You can specify the schema in your dip.yml using the `$schema` property: + +```yml +$schema: https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json + +version: '8.1.0' +# ... rest of your config +``` + +The validator will check: + +- Required properties are present +- Property types are correct +- Values match expected patterns +- No unknown properties are used + +If validation fails, you'll get detailed error messages indicating what needs to be fixed. + ## Changelog https://github.com/bibendi/dip/releases diff --git a/dip.gemspec b/dip.gemspec index 6c1463f..18a1f6c 100644 --- a/dip.gemspec +++ b/dip.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.glob("lib/**/*") + Dir.glob("exe/*") + %w[LICENSE.txt README.md] + spec.files = Dir.glob("lib/**/*") + Dir.glob("exe/*") + %w[LICENSE.txt README.md schema.json] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 2.7" spec.add_dependency "thor", ">= 0.20", "< 2" + spec.add_dependency "json-schema", "~> 5" spec.add_development_dependency "bundler", ">= 1.15" spec.add_development_dependency "pry-byebug", "~> 3" diff --git a/examples/dip.yml b/examples/dip.yml new file mode 100644 index 0000000..d68d78b --- /dev/null +++ b/examples/dip.yml @@ -0,0 +1,133 @@ +$schema: https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json + +version: '8.1.0' + +environment: + RAILS_ENV: development + NODE_ENV: development + DATABASE_URL: postgres://user:password@db:5432/myapp_development + REDIS_URL: redis://redis:6379/0 + PORT: ${PORT:-3000} + APP_PORT: ${PORT:-3000} + +compose: + files: + - docker-compose.yml + - docker-compose.override.yml + project_name: myapp_project + command: docker compose + +interaction: + rails: + description: Run Rails commands + service: web + command: bundle exec rails + default_args: server -p 3000 -b 0.0.0.0 + environment: + RAILS_LOG_TO_STDOUT: "true" + compose: + method: run + compose_method: up + run_options: + - service-ports + - rm + profiles: + - web + - development + shell: true + entrypoint: /docker-entrypoint.sh + runner: docker_compose + subcommands: + console: + description: Start Rails console + command: console + routes: + description: Show Rails routes + command: routes + db: + description: Database related commands + subcommands: + migrate: + description: Run database migrations + command: db:migrate + seed: + description: Seed the database + command: db:seed + + npm: + description: Run npm commands + service: frontend + command: npm + compose: + method: run + profiles: + - frontend + + psql: + description: Connect to PostgreSQL database + service: db + command: psql -h db -U user myapp_development + compose: + method: run + environment: + PGPASSWORD: password + + rspec: + description: Run RSpec tests + service: web + command: bundle exec rspec + environment: + RAILS_ENV: test + compose: + method: run + run_options: + - rm + profiles: + - test + + shell: + description: Start a shell in the web container + service: web + command: /bin/bash + compose: + method: run + run_options: + - rm + + k8s: + description: Run kubectl commands + command: kubectl + runner: kubectl + entrypoint: kubectl + shell: false + + brakeman: + description: Check brakeman sast + command: docker run another-image ... + + rake: + description: Run Rake tasks + service: web + command: bundle exec rake + +provision: + - dip compose down --volumes + - dip compose build + - dip rails db:create + - dip rails db:migrate + - dip rails db:seed + - dip npm install + - dip validate + +kubectl: + namespace: myapp-development + +modules: + - production + +infra: + redis: + git: https://github.com/mycompany/redis-config.git + ref: main + elasticsearch: + path: ./infra/elasticsearch diff --git a/lib/dip/cli.rb b/lib/dip/cli.rb index 15e66df..c644f1f 100644 --- a/lib/dip/cli.rb +++ b/lib/dip/cli.rb @@ -5,7 +5,7 @@ module Dip class CLI < Thor - TOP_LEVEL_COMMANDS = %w[help version ls compose up stop down run provision ssh infra console].freeze + TOP_LEVEL_COMMANDS = %w[help version ls compose up stop down run provision ssh infra console validate] class << self # Hackery. Take the run method away from Thor so that we can redefine it. @@ -117,6 +117,15 @@ def provision end end + desc "validate", "Validate the dip.yml file against the schema" + def validate + Dip.config.validate + puts "dip.yml is valid" + rescue Dip::Error => e + warn "Validation failed: #{e.message}" + exit 1 + end + require_relative "cli/ssh" desc "ssh", "ssh-agent container commands" subcommand :ssh, Dip::CLI::SSH diff --git a/lib/dip/config.rb b/lib/dip/config.rb index 393af11..247f87d 100644 --- a/lib/dip/config.rb +++ b/lib/dip/config.rb @@ -3,6 +3,7 @@ require "yaml" require "erb" require "pathname" +require "json-schema" require "dip/version" require "dip/ext/hash" @@ -112,6 +113,24 @@ def to_h end end + def validate + raise Dip::Error, "Config file path is not set" if file_path.nil? + raise Dip::Error, "Config file not found: #{file_path}" unless File.exist?(file_path) + + schema_path = File.join(File.dirname(__FILE__), "../../schema.json") + raise Dip::Error, "Schema file not found: #{schema_path}" unless File.exist?(schema_path) + + data = YAML.load_file(file_path) + schema = JSON.parse(File.read(schema_path)) + JSON::Validator.validate!(schema, data) + rescue Psych::SyntaxError => e + raise Dip::Error, "Invalid YAML syntax in config file: #{e.message}" + rescue JSON::Schema::ValidationError => e + data_display = data ? data.to_yaml.gsub("\n", "\n ") : "nil" + error_message = "Schema validation failed: #{e.message}\nInput data:\n #{data_display}" + raise Dip::Error, error_message + end + private attr_reader :work_dir @@ -129,8 +148,8 @@ def config unless Gem::Version.new(Dip::VERSION) >= Gem::Version.new(config.fetch(:version)) raise VersionMismatchError, "Your dip version is `#{Dip::VERSION}`, " \ - "but config requires minimum version `#{config[:version]}`. " \ - "Please upgrade your dip!" + "but config requires minimum version `#{config[:version]}`. " \ + "Please upgrade your dip!" end base_config = {} @@ -155,6 +174,10 @@ def config base_config.deep_merge!(self.class.load_yaml(override_finder.file_path)) if override_finder.exist? @config = CONFIG_DEFAULTS.merge(base_config) + + validate + + @config end def config_missing_error(config_key) diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..13b16fc --- /dev/null +++ b/schema.json @@ -0,0 +1,229 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "title": "Dip Configuration Schema", + "description": "Schema for the dip.yml configuration file", + "type": "object", + "additionalProperties": false, + "definitions": { + "environment_vars": { + "type": "object", + "description": "Defines environment variables", + "additionalProperties": { + "type": "string" + }, + "examples": { + "RAILS_ENV": "development", + "DATABASE_URL": "postgres://user:password@db:5432/myapp_development", + "PORT": "${PORT:-3000}" + } + }, + "interaction_command": { + "type": "object", + "description": "Configuration for an interaction command", + "additionalProperties": false, + "properties": { + "description": { + "type": "string", + "description": "Describes the command", + "examples": ["Run Rails commands", "Connect to PostgreSQL database"] + }, + "service": { + "type": "string", + "description": "Specifies the service associated with the command", + "examples": ["web", "frontend", "db"] + }, + "command": { + "type": "string", + "description": "Represents the command to be executed", + "examples": ["bundle exec rails", "npm", "psql -h db -U user myapp_development"] + }, + "default_args": { + "type": "string", + "description": "Default arguments for the command", + "examples": ["server -p 3000 -b 0.0.0.0"] + }, + "environment": { + "$ref": "#/definitions/environment_vars" + }, + "compose": { + "type": "object", + "description": "Allows specifying Docker Compose options", + "additionalProperties": false, + "properties": { + "method": { + "type": "string", + "description": "Specifies the Docker Compose method (e.g., up, run)", + "examples": ["run", "up"] + }, + "compose_method": { + "type": "string", + "description": "Specifies an alternative Docker Compose method to use in compose commands", + "examples": ["up"] + }, + "run_options": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Options to pass to the 'docker-compose run' command", + "examples": [["service-ports", "rm"]] + }, + "profiles": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Docker Compose profiles to use", + "examples": [["web", "development"], ["frontend"], ["test"]] + } + } + }, + "shell": { + "type": "boolean", + "description": "Enables or disables shell interpolation" + }, + "entrypoint": { + "type": "string", + "description": "Specifies the command entrypoint" + }, + "runner": { + "type": "string", + "description": "Specifies the runner (e.g., docker_compose, kubectl)" + }, + "subcommands": { + "type": "object", + "description": "Contains subcommands with the same structure as main commands", + "patternProperties": { + "^[a-zA-Z0-9_]+$": { + "$ref": "#/definitions/interaction_command" + } + }, + "minProperties": 1, + "additionalProperties": false + } + } + } + }, + "properties": { + "$schema": { + "type": "string", + "pattern": "^(https?://[^\\s/$.?#].[^\\s]*|\\./|/).+$", + "description": "The URI of the JSON Schema to validate against" + }, + "version": { + "type": "string", + "description": "Specifies the minimum required version of Dip", + "examples": ["8.1.0"] + }, + "compose": { + "type": "object", + "description": "Contains Docker Compose configuration", + "properties": { + "files": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Array of strings representing paths to Docker Compose files", + "examples": [["docker-compose.yml", "docker-compose.override.yml"]] + }, + "project_name": { + "type": "string", + "description": "Specifies the project name for Docker Compose", + "examples": ["app"] + }, + "command": { + "type": "string", + "description": "Specifies an alternative Docker Compose command", + "examples": ["docker compose"] + }, + "method": { + "type": "string", + "description": "Specifies the Docker Compose method to use" + } + } + }, + "interaction": { + "type": "object", + "description": "Defines the commands and their configurations", + "patternProperties": { + "^[a-zA-Z0-9_]+$": { + "$ref": "#/definitions/interaction_command" + } + }, + "additionalProperties": false + }, + "provision": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Lists the commands to be executed for provisioning", + "examples": [ + [ + "dip compose down --volumes", + "dip compose build", + "dip rails db:migrate", + "dip npm install" + ] + ] + }, + "environment": { + "$ref": "#/definitions/environment_vars" + }, + "kubectl": { + "type": "object", + "description": "Contains Kubernetes configuration", + "additionalProperties": false, + "properties": { + "namespace": { + "type": "string", + "description": "Specifies the Kubernetes namespace to use", + "examples": ["app"] + } + } + }, + "modules": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Paths to module configuration files", + "examples": [["production"]] + }, + "infra": { + "type": "object", + "description": "Contains infrastructure services configuration", + "additionalProperties": false, + "patternProperties": { + "^[a-zA-Z0-9_]+$": { + "type": "object", + "additionalProperties": false, + "properties": { + "git": { + "type": "string", + "pattern": "^(git@|git://|https?://)[\\w\\d\\.@:\\-/]+$", + "description": "Git repository URL for the infrastructure component", + "examples": ["https://github.com/mycompany/redis-config.git"] + }, + "ref": { + "type": "string", + "description": "Specifies the Git reference (branch, tag, or commit) to use", + "examples": ["main"] + }, + "path": { + "type": "string", + "description": "Local path to the infrastructure component", + "examples": ["./infra/elasticsearch"] + } + }, + "oneOf": [ + { "required": ["git", "ref"] }, + { "required": ["path"] } + ] + } + } + } + }, + "required": ["version", "interaction"] +} diff --git a/spec/fixtures/invalid-with-schema/dip.yml b/spec/fixtures/invalid-with-schema/dip.yml new file mode 100644 index 0000000..60fd9ff --- /dev/null +++ b/spec/fixtures/invalid-with-schema/dip.yml @@ -0,0 +1,9 @@ +$schema: ./schema.json + +environment: {} + +compose: {} + +interaction: {} + +provision: [] diff --git a/spec/fixtures/no-schema/dip.yml b/spec/fixtures/no-schema/dip.yml new file mode 100644 index 0000000..4f9c0a7 --- /dev/null +++ b/spec/fixtures/no-schema/dip.yml @@ -0,0 +1,9 @@ +version: '7' + +environment: {} + +compose: {} + +interaction: {} + +provision: [] diff --git a/spec/lib/dip/config_spec.rb b/spec/lib/dip/config_spec.rb index cdda41e..f2c5ac7 100644 --- a/spec/lib/dip/config_spec.rb +++ b/spec/lib/dip/config_spec.rb @@ -97,4 +97,36 @@ ) end end + + describe "#validate" do + context "when schema is valid" do + it "does not raise an error" do + expect { subject.validate }.not_to raise_error + end + end + + context "when schema is invalid", :env do + let(:env) { {"DIP_FILE" => fixture_path("invalid-with-schema/dip.yml")} } + + it "raises a Dip::Error" do + expect { subject.validate }.to raise_error(Dip::Error, /Schema validation failed/) + end + end + + context "when config file is not found", :env do + let(:env) { {"DIP_FILE" => "no.yml"} } + + it "raises a Dip::Error" do + expect { subject.validate }.to raise_error(Dip::Error, /Config file not found/) + end + end + + context "when schema file is not found", :env do + let(:env) { {"DIP_FILE" => fixture_path("no-schema", "dip.yml")} } + + it "does not raise an error" do + expect { subject.validate }.not_to raise_error + end + end + end end From b7f4c8f31c4caf9bc2748a9813116aa2de525d2d Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Tue, 19 Nov 2024 15:23:13 +0100 Subject: [PATCH 02/10] Add option to skip validation with env variable --- README.md | 2 ++ lib/dip/config.rb | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f93540..cd9c150 100644 --- a/README.md +++ b/README.md @@ -498,6 +498,8 @@ The validator will check: If validation fails, you'll get detailed error messages indicating what needs to be fixed. +You can skip validation by setting `DIP_SKIP_VALIDATION` environment variable. + ## Changelog https://github.com/bibendi/dip/releases diff --git a/lib/dip/config.rb b/lib/dip/config.rb index 247f87d..3437a94 100644 --- a/lib/dip/config.rb +++ b/lib/dip/config.rb @@ -175,7 +175,9 @@ def config @config = CONFIG_DEFAULTS.merge(base_config) - validate + unless ENV.key?("DIP_SKIP_VALIDATION") + validate + end @config end From e53e4fd4e3f3a38ec098b128f9f04c8945c84795 Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Tue, 19 Nov 2024 15:48:57 +0100 Subject: [PATCH 03/10] Remove schema validation references and unused schema file --- README.md | 9 --------- examples/dip.yml | 2 -- schema.json | 5 ----- spec/fixtures/invalid-with-schema/dip.yml | 2 -- 4 files changed, 18 deletions(-) diff --git a/README.md b/README.md index cd9c150..88078d3 100644 --- a/README.md +++ b/README.md @@ -480,15 +480,6 @@ Validates your dip.yml configuration against the JSON schema. The schema validat dip validate ``` -You can specify the schema in your dip.yml using the `$schema` property: - -```yml -$schema: https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json - -version: '8.1.0' -# ... rest of your config -``` - The validator will check: - Required properties are present diff --git a/examples/dip.yml b/examples/dip.yml index d68d78b..37f82d1 100644 --- a/examples/dip.yml +++ b/examples/dip.yml @@ -1,5 +1,3 @@ -$schema: https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json - version: '8.1.0' environment: diff --git a/schema.json b/schema.json index 13b16fc..5ab0161 100644 --- a/schema.json +++ b/schema.json @@ -105,11 +105,6 @@ } }, "properties": { - "$schema": { - "type": "string", - "pattern": "^(https?://[^\\s/$.?#].[^\\s]*|\\./|/).+$", - "description": "The URI of the JSON Schema to validate against" - }, "version": { "type": "string", "description": "Specifies the minimum required version of Dip", diff --git a/spec/fixtures/invalid-with-schema/dip.yml b/spec/fixtures/invalid-with-schema/dip.yml index 60fd9ff..e4d998d 100644 --- a/spec/fixtures/invalid-with-schema/dip.yml +++ b/spec/fixtures/invalid-with-schema/dip.yml @@ -1,5 +1,3 @@ -$schema: ./schema.json - environment: {} compose: {} From d66a159b07531f326e81a9386b1170e19023dfe7 Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Tue, 19 Nov 2024 15:52:10 +0100 Subject: [PATCH 04/10] Add schema validation instructions for VSCode in README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 88078d3..91e11e6 100644 --- a/README.md +++ b/README.md @@ -491,6 +491,8 @@ If validation fails, you'll get detailed error messages indicating what needs to You can skip validation by setting `DIP_SKIP_VALIDATION` environment variable. +Add `// yaml-language-server: $schema=https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json` to the top of your dip.yml to get schema validation in VSCode. Read more about [YAML Language Server](https://github.com/redhat-developer/vscode-yaml?tab=readme-ov-file#associating-schemas). + ## Changelog https://github.com/bibendi/dip/releases From 129115ee8ebead101f307eb1751ceca90e28fe78 Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Tue, 19 Nov 2024 15:56:11 +0100 Subject: [PATCH 05/10] Add schema validation for dip.yml using ajv --- README.md | 2 +- dip.yml | 7 +++++++ docker-compose.yml | 7 +++++++ schema.json | 10 +++++----- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 91e11e6..1b4bf10 100644 --- a/README.md +++ b/README.md @@ -491,7 +491,7 @@ If validation fails, you'll get detailed error messages indicating what needs to You can skip validation by setting `DIP_SKIP_VALIDATION` environment variable. -Add `// yaml-language-server: $schema=https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json` to the top of your dip.yml to get schema validation in VSCode. Read more about [YAML Language Server](https://github.com/redhat-developer/vscode-yaml?tab=readme-ov-file#associating-schemas). +Add `# yaml-language-server: $schema=https://raw.githubusercontent.com/bibendi/dip/refs/heads/master/schema.json` to the top of your dip.yml to get schema validation in VSCode. Read more about [YAML Language Server](https://github.com/redhat-developer/vscode-yaml?tab=readme-ov-file#associating-schemas). ## Changelog diff --git a/dip.yml b/dip.yml index 661a1eb..29b1f3a 100644 --- a/dip.yml +++ b/dip.yml @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=./schema.json + version: '7' compose: @@ -30,6 +32,11 @@ interaction: service: app command: bundle exec rubocop + validate: + description: Validate dip.yml files against schema.json + service: schema + command: npm install -g ajv && ajv -s schema -d */**/dip.yml + provision: - cp -f lefthook-local.dip_example.yml lefthook-local.yml - dip compose down --volumes diff --git a/docker-compose.yml b/docker-compose.yml index a8750eb..9224a42 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,13 @@ services: volumes: - .:/app - bundle:/bundle + schema: + image: node:${NODE_IMAGE:-20} + environment: + - HISTFILE=/app/tmp/.bash_history + working_dir: /app + volumes: + - .:/app volumes: bundle: diff --git a/schema.json b/schema.json index 5ab0161..bc3b774 100644 --- a/schema.json +++ b/schema.json @@ -11,11 +11,11 @@ "additionalProperties": { "type": "string" }, - "examples": { - "RAILS_ENV": "development", - "DATABASE_URL": "postgres://user:password@db:5432/myapp_development", - "PORT": "${PORT:-3000}" - } + "examples": [ + { "RAILS_ENV": "development" }, + { "DATABASE_URL": "postgres://user:password@db:5432/myapp_development" }, + { "PORT": "${PORT:-3000}" } + ] }, "interaction_command": { "type": "object", From a522c023af50272cf8906b52c2cef0a236771fc7 Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Tue, 19 Nov 2024 16:03:31 +0100 Subject: [PATCH 06/10] Remove schema service from docker-compose.yml and dip.yml validation --- dip.yml | 5 ----- docker-compose.yml | 7 ------- 2 files changed, 12 deletions(-) diff --git a/dip.yml b/dip.yml index 29b1f3a..8486cd2 100644 --- a/dip.yml +++ b/dip.yml @@ -32,11 +32,6 @@ interaction: service: app command: bundle exec rubocop - validate: - description: Validate dip.yml files against schema.json - service: schema - command: npm install -g ajv && ajv -s schema -d */**/dip.yml - provision: - cp -f lefthook-local.dip_example.yml lefthook-local.yml - dip compose down --volumes diff --git a/docker-compose.yml b/docker-compose.yml index 9224a42..a8750eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,13 +9,6 @@ services: volumes: - .:/app - bundle:/bundle - schema: - image: node:${NODE_IMAGE:-20} - environment: - - HISTFILE=/app/tmp/.bash_history - working_dir: /app - volumes: - - .:/app volumes: bundle: From e8444cced22f6a90f95a7a2c42a9d18d199304ea Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Mon, 25 Nov 2024 10:21:43 +0100 Subject: [PATCH 07/10] Add development dependency on public_suffix gem --- dip.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/dip.gemspec b/dip.gemspec index 18a1f6c..5e91add 100644 --- a/dip.gemspec +++ b/dip.gemspec @@ -46,5 +46,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rubocop-rspec", "~> 2.2" spec.add_development_dependency "simplecov", "~> 0.16" spec.add_development_dependency "test-unit", "~> 3" + spec.add_development_dependency "public_suffix", ">= 2.0.2", "< 7.0" spec.add_development_dependency "fakefs" end From 4c942076b16290949ffb0bceedc82dab6d19c8d3 Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Mon, 25 Nov 2024 10:24:30 +0100 Subject: [PATCH 08/10] Add public_suffix as dependency in gemspec --- dip.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip.gemspec b/dip.gemspec index 5e91add..b1e8ac9 100644 --- a/dip.gemspec +++ b/dip.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_dependency "thor", ">= 0.20", "< 2" spec.add_dependency "json-schema", "~> 5" + spec.add_dependency "public_suffix", ">= 2.0.2", "< 7.0" spec.add_development_dependency "bundler", ">= 1.15" spec.add_development_dependency "pry-byebug", "~> 3" @@ -46,6 +47,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rubocop-rspec", "~> 2.2" spec.add_development_dependency "simplecov", "~> 0.16" spec.add_development_dependency "test-unit", "~> 3" - spec.add_development_dependency "public_suffix", ">= 2.0.2", "< 7.0" spec.add_development_dependency "fakefs" end From 5733ae95e401b62f245104eae20bb1f446e2f08a Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Mon, 25 Nov 2024 10:26:39 +0100 Subject: [PATCH 09/10] Add comment about public_suffix version compatibility --- dip.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dip.gemspec b/dip.gemspec index b1e8ac9..9b7c1de 100644 --- a/dip.gemspec +++ b/dip.gemspec @@ -36,6 +36,8 @@ Gem::Specification.new do |spec| spec.add_dependency "thor", ">= 0.20", "< 2" spec.add_dependency "json-schema", "~> 5" + # public_suffix >= 7.0 requires Ruby >= 3.0, so we need to specify an upper bound + # to maintain compatibility with Ruby 2.7 spec.add_dependency "public_suffix", ">= 2.0.2", "< 7.0" spec.add_development_dependency "bundler", ">= 1.15" From 5bf2e54450772feab8cf5341928627851657f04f Mon Sep 17 00:00:00 2001 From: Linus Oleander Date: Mon, 25 Nov 2024 11:02:27 +0100 Subject: [PATCH 10/10] Update public_suffix dependency version upper bound --- dip.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dip.gemspec b/dip.gemspec index 9b7c1de..da257cd 100644 --- a/dip.gemspec +++ b/dip.gemspec @@ -36,9 +36,9 @@ Gem::Specification.new do |spec| spec.add_dependency "thor", ">= 0.20", "< 2" spec.add_dependency "json-schema", "~> 5" - # public_suffix >= 7.0 requires Ruby >= 3.0, so we need to specify an upper bound + # public_suffix >= 6.0 requires Ruby >= 3.0, so we need to specify an upper bound # to maintain compatibility with Ruby 2.7 - spec.add_dependency "public_suffix", ">= 2.0.2", "< 7.0" + spec.add_dependency "public_suffix", ">= 2.0.2", "< 6.0" spec.add_development_dependency "bundler", ">= 1.15" spec.add_development_dependency "pry-byebug", "~> 3"