Skip to content

Command Line Tool

The erm-cli is built on:

Usage:

npm run erm

Prompts will guide the tool.

Features

index.js is the orchestrator of all cli functions.

Add new content file (prompts for frontmatter and file type)

content.js

Add new image netadata sidecar

imageMetadataFileGenerator.js

This module provides helper functions and constants to support generating and managing image metadata sidecar files (.json). It facilitates user prompts, file selection, path resolution, and metadata file creation.

🧩 Exports

default A named export imageMetadataGenerator, which includes the following:

  • ADD_IMAGE_METADATA_TEXT
  • checkMetadataFileExists
  • createMetadataContent
  • createMetadataPrompts
  • createOverwritePrompt
  • generateMetadataFilePath
  • selectSourceImageFile
  • writeMetadataFile

🔹 Constants

ADD_IMAGE_METADATA_TEXT

Descriptive label text: “Add image metadata sidecar”.

🧮 Prompt Functions

createOverwritePrompt()

Returns an inquirer prompt array asking whether to overwrite an existing file.

createMetadataPrompts()

Returns a series of input prompts to gather metadata such as:

  • Source URL
  • Title
  • Alt text
  • Creator name and link
  • License name and link

📁 File I/O Functions

checkMetadataFileExists(metadataFilePath: string): Promise

Checks whether the metadata .json file already exists.

writeMetadataFile(metadataFilePath: string, jsonContent: string): Promise

Writes the metadata JSON content to the given file path using UTF-8 encoding.

🛠️ Utility Functions

generateMetadataFilePath(sourceImagePath: string): string

Generates a JSON sidecar path for the given image file, e.g. /images/dog.jpg → /images/dog.json.

createMetadataContent(metadataValues: Record<string, string>): string

Generates a formatted JSON string from metadata inputs, including a createdAt timestamp.

🖼️ File Selection

selectSourceImageFile(): Promise

Opens a native file dialog restricted to image files and returns the selected file path. Throws an error if no file is selected.

Bugs

  • List of tags is inacurate, not a unique set.

  • Date should not be output as string