Sha256: 692fe686248b3b027c2e461aed7c8742d739bdb9ca268ed0a5f6cfe95cb6bbcc

Contents?: true

Size: 974 Bytes

Versions: 18

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

require "pathname"

module Script
  module Layers
    module Infrastructure
      class AssemblyScriptTsConfig
        TSCONFIG_FILE = "tsconfig.json"

        attr_reader :config

        def initialize(dir_to_write_in:)
          @dir_to_write_in = dir_to_write_in
          @config = {}
        end

        def with_extends_assemblyscript_config(relative_path_to_node_modules:)
          relative_path = Pathname.new(relative_path_to_node_modules).relative_path_from(@dir_to_write_in)
          @config[:extends] = "#{relative_path}/node_modules/assemblyscript/std/assembly.json"
          self
        end

        def with_module_resolution_paths(paths:)
          @config[:compilerOptions] = {
            baseUrl: ".",
            paths: paths,
          }
          self
        end

        def write
          File.write("#{@dir_to_write_in}/#{TSCONFIG_FILE}", JSON.pretty_generate(@config))
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
shopify-cli-1.4.1 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.4.0 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.3.1 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.3.0 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.2.0 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.1.2 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.1.1 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.1.0 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.0.5 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.0.4 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.0.3 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.0.2 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.0.1 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-1.0.0 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-0.9.3 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-0.9.2 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-0.9.1 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb
shopify-cli-0.9.0 lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb