@shopify/cli-kit
    Preparing search index...

    General-purpose TOML file abstraction.

    Provides a unified interface for reading, patching, removing keys from, and replacing the content of TOML files on disk.

    • read populates content from disk
    • patch does surgical WASM-based edits (preserves comments and formatting)
    • remove deletes a key by dotted path (preserves comments and formatting)
    • replace does a full re-serialization (comments and formatting are NOT preserved).
    • transformRaw applies a function to the raw TOML string on disk.
    Index

    Constructors

    Properties

    content: JsonMap
    path: string

    Methods

    • Surgically patch values in the TOML file, preserving comments and formatting.

      Accepts a nested object whose leaf values are set in the TOML. Intermediate tables are created automatically. Setting a leaf to undefined removes it (use remove() for a clearer API when deleting keys).

      Parameters

      • changes: { [key: string]: unknown }

      Returns Promise<void>

      await file.patch({build: {dev_store_url: 'my-store.myshopify.com'}})
      await file.patch({application_url: 'https://example.com', auth: {redirect_urls: ['...']}})
    • Remove a key from the TOML file by dotted path, preserving comments and formatting.

      Parameters

      • keyPath: string

        Dotted key path to remove (e.g. 'build.include_config_on_deploy').

      Returns Promise<void>

      await file.remove('build.include_config_on_deploy')
      
    • Replace the entire file content. The file is fully re-serialized — comments and formatting are NOT preserved.

      Parameters

      • content: JsonMap

        The new content to write.

      Returns Promise<void>

      await file.replace({client_id: 'abc', name: 'My App'})
      
    • Transform the raw TOML string on disk. Reads the file, applies the transform function to the raw text, writes back, and re-parses to keep content in sync.

      Use this for text-level operations that can't be expressed as structured edits — e.g. Injecting comments or positional insertion of keys in arrays-of-tables. Subsequent patch() calls will preserve any comments added this way.

      Parameters

      • transform: (raw: string) => string

        A function that receives the raw TOML string and returns the modified string.

      Returns Promise<void>

      await file.transformRaw((raw) => `# Header comment\n${raw}`)