Represents a theme on the file system.

interface ThemeFileSystem {
    addEventListener: <T extends ThemeFSEventName>(
        eventName: T,
        cb: (params: ThemeFSEventPayload<T>) => void,
    ) => void;
    applyIgnoreFilters: <T extends { key: string }>(files: T[]) => T[];
    delete: (fileKey: string) => Promise<void>;
    files: Map<string, ThemeAsset>;
    read: (fileKey: string) => Promise<undefined | string | Buffer>;
    ready: () => Promise<void>;
    root: string;
    startWatcher: (
        themeId: string,
        adminSession: AdminSession,
    ) => Promise<void>;
    unsyncedFileKeys: Set<string>;
    uploadErrors: Map<string, string[]>;
    write: (asset: ThemeAsset) => Promise<void>;
}

Hierarchy (View Summary)

Properties

addEventListener: <T extends ThemeFSEventName>(
    eventName: T,
    cb: (params: ThemeFSEventPayload<T>) => void,
) => void

Add callbacks to run after certain events are fired.

applyIgnoreFilters: <T extends { key: string }>(files: T[]) => T[]

Applies filters to ignore files from .shopifyignore file, --ignore and --only flags.

delete: (fileKey: string) => Promise<void>

Removes a file from the local disk and updates the file system

Type declaration

    • (fileKey: string): Promise<void>
    • Parameters

      • fileKey: string

        The key of the file to remove

      Returns Promise<void>

files: Map<string, ThemeAsset>

Local files.

read: (fileKey: string) => Promise<undefined | string | Buffer>

Reads a file from the local disk and updates the file system Returns a ThemeAsset representing the file that was read Returns undefined if the file does not exist

Type declaration

    • (fileKey: string): Promise<undefined | string | Buffer>
    • Parameters

      • fileKey: string

        The key of the file to read

      Returns Promise<undefined | string | Buffer>

ready: () => Promise<void>

Promise that resolves when all the initial files are found.

root: string

The root path of the theme.

startWatcher: (themeId: string, adminSession: AdminSession) => Promise<void>

Starts a file watcher for the theme directory.

Type declaration

    • (themeId: string, adminSession: AdminSession): Promise<void>
    • Parameters

      • themeId: string

        The ID of the theme being watched.

      • adminSession: AdminSession

        The admin session for API communication.

      Returns Promise<void>

      A Promise that resolves to an FSWatcher instance.

unsyncedFileKeys: Set<string>

File keys that have been modified in memory and are not uploaded yet.

uploadErrors: Map<string, string[]>

Stores upload errors returned when uploading files via the Asset API

write: (asset: ThemeAsset) => Promise<void>

Writes a file to the local disk and updates the file system

Type declaration

    • (asset: ThemeAsset): Promise<void>
    • Parameters

      • asset: ThemeAsset

        The ThemeAsset representing the file to write

      Returns Promise<void>