Member Junction
    Preparing search index...

    File system adapter providing all I/O operations needed by installer phases.

    Methods are organized into categories:

    Index

    Constructors

    Methods

    • Test whether the current process can write to a directory.

      Creates the directory if it doesn't exist, writes a temporary probe file, then deletes it. Returns false if any step fails (permission denied, etc.).

      Parameters

      • dirPath: string

        Directory path to test write access for.

      Returns Promise<boolean>

      true if a file can be written and deleted in the directory.

    • Create a temporary directory in the system temp folder.

      Parameters

      • prefix: string = 'mj-install-'

        Directory name prefix (default: 'mj-install-').

      Returns Promise<string>

      Absolute path to the created temporary directory.

    • Check whether a path exists and is a directory.

      Parameters

      • dirPath: string

        Absolute path to check.

      Returns Promise<boolean>

      true if the path exists and is a directory, false otherwise.

    • Extract a ZIP file into a target directory.

      Handles the common GitHub zipball convention where all files are nested inside a single root folder (e.g., MemberJunction-MJ-abc1234/). When a single root folder is detected, its contents are extracted directly into targetDir without the wrapper folder.

      Entries are written by hand rather than through adm-zip's extractAllTo / extractEntryTo on purpose: those sanitize an escaping entry by silently relocating it under the target, and a tampered release must fail, not be quietly repaired. Do not substitute them for the loop below.

      Parameters

      • zipPath: string

        Absolute path to the ZIP file.

      • targetDir: string

        Directory to extract into (created if it doesn't exist).

      Returns Promise<string[]>

      List of top-level entry names in the target directory after extraction.

      Error if the ZIP file is corrupt or unreadable.

      if any entry would be written outside targetDir (a "zip slip" archive). Entries are validated before anything is written, so a refused archive leaves the target directory untouched.

      const entries = await fs.ExtractZip('/tmp/v5.1.0.zip', '/path/to/install');
      // ['packages', 'package.json', 'turbo.json', ...]
    • Check whether a path exists and is a regular file.

      Parameters

      • filePath: string

        Absolute path to check.

      Returns Promise<boolean>

      true if the path exists and is a file, false otherwise.

    • Recursively search for files with a specific name under a directory.

      Skips node_modules and .git directories to avoid excessive traversal. Used by PlatformCompatPhase to find all package.json files in the workspace.

      Parameters

      • dirPath: string

        Root directory to start the search from.

      • filename: string

        Exact file name to match (e.g., 'package.json').

      • maxDepth: number = 3

        Maximum directory depth to recurse into (default: 3).

      Returns Promise<string[]>

      Array of absolute paths to matching files.

    • Get free disk space in bytes at a given path.

      Walks up the directory tree to find an existing ancestor if dirPath doesn't exist yet (common for fresh installs). Uses fs.statfs() to query available blocks.

      Parameters

      • dirPath: string

        Path to check free space for (can be non-existent).

      Returns Promise<number>

      Available disk space in bytes.

      Error if the filesystem stats cannot be read.

    • Get the last-modified time of a file in milliseconds since the Unix epoch.

      Used by CodeGenPhase's fast mode to compare source vs compiled file timestamps and determine whether post-codegen rebuilds are needed.

      Parameters

      • filePath: string

        Absolute path to the file.

      Returns Promise<number>

      Modification time in milliseconds, or null if the file doesn't exist.

    • Check whether a directory is empty (contains no files or subdirectories).

      Parameters

      • dirPath: string

        Absolute path to the directory.

      Returns Promise<boolean>

      true if the directory is empty or doesn't exist, false otherwise.

    • List file names in a directory, optionally filtered by a regex pattern. Returns only regular files (not directories).

      Parameters

      • dirPath: string

        Absolute path to the directory.

      • Optionalpattern: RegExp

        Optional regex to filter file names (e.g., /environment.*\.ts$/).

      Returns Promise<string[]>

      Array of matching file names (not full paths). Empty if directory doesn't exist.

    • Read a file's raw bytes (no encoding interpretation). Useful for hashing or binary diffs where UTF-8 round-tripping would corrupt the content.

      Parameters

      • filePath: string

        Absolute path to the file.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      File content as a Uint8Array.

      Error if the file doesn't exist.

    • Read and parse a JSON file.

      Type Parameters

      • T

        Expected shape of the parsed JSON.

      Parameters

      • filePath: string

        Absolute path to the JSON file.

      Returns Promise<T>

      Parsed JSON content cast to type T.

      Error if the file doesn't exist or contains invalid JSON.

    • Read a UTF-8 text file and return its content as a string.

      Parameters

      • filePath: string

        Absolute path to the file.

      Returns Promise<string>

      File content as a string.

      Error if the file doesn't exist.

    • Serialize data as JSON and write it to a file (pretty-printed, 2-space indent).

      Parameters

      • filePath: string

        Absolute path to write the JSON file.

      • data: unknown

        Data to serialize.

      Returns Promise<void>

    • Write a UTF-8 text file, creating parent directories if needed. Used for .env, SQL scripts, environment.ts, and manifest files.

      Parameters

      • filePath: string

        Absolute path to write the file.

      • content: string

        Text content to write.

      Returns Promise<void>