Skip to content

Instantly share code, notes, and snippets.

@IshaanAdarsh
Last active March 26, 2024 22:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IshaanAdarsh/a17f58f4252a3f40b8f2a0caa38ea173 to your computer and use it in GitHub Desktop.
Save IshaanAdarsh/a17f58f4252a3f40b8f2a0caa38ea173 to your computer and use it in GitHub Desktop.
Omnigres(pgpm)

Improvements/Enhancements for PGPM:

Enhanced Metadata:

  • Move away from PGXN type META.json metadat form or stick to it? We could think of a way to impove metadata colletion for an extension. (but sticking to a widely accepted standard like PGXN or considering improvements aligns with best practices)

Automatic Dependency Installation:(kinda like homebrew)

-(Provide users with options for manual intervention in case they want more control over dependencies)

Version Support:

  • Saw some ideas about an omnigres version(isolated extension architecture) or something like Collaborative Versioning System(for multiple people fworking on an extension). Mabye integrate that and discuss some more about if that will be feasible.
  • a rollback mechanism to revert to previous package versions, helping users recover from unexpected issues.

Robust Error Handling and Logging:

The current error handling and logging give minimal insights into potential issues (no real section dedicated to it)

  • a standardized error format is needed for it

Security Measures:

Current PGPM lacks robust security checks (could learn from npm)

  • Package integrity verification
  • Vulnerability scanning
  • Validation during the installation process

Comprehensive Documentation:

  • I will be documenting everything as we go on so onboarding will be easier also easier to track changes.

Predictive Autocomplete for Commands:

  • Predictive autocomplete while typing commands to assist users in the package management process.

pgpm Website:

Interactive Package Visualization and History.

  • An interactive graphical tool that visualizes a package's history, depicting commits, releases, and version changes. Like Gitkraken(dependency graphs ).

Gamified Collaborative Package Development:

  • multiple developers can work on the same package simultaneously. a gamification element where developers earn rewards or recognition for contributing to package development (like Github)

User Feedback Integration:

  • Integrate a user feedback system within the package manager interface. A rating and review system for packages, fostering a community-driven approach to package quality assessment

Package Health Dashboard:

  • Health status of installed packages, including security alerts, updates, and vulnerabilities.
- PGPM Directory Structure

  - Core Files:
    - pgpm/pgpm.lgt
    - pgpm/loader.lgt

  - Functional Modules:
    - Configuration & Metadata:
      - pgpm/config.lgt
      - pgpm/metadata.lgt

    - Git & Versioning:
      - pgpm/git_rev.lgt
      - pgpm/git_remote.lgt
      - pgpm/git.lgt
      - pgpm/version.lgt

    - Package Management:
      - pgpm/package.lgt
      - pgpm/tagged.lgt
      - pgpm/requirement.lgt

    - Environment & OS:
      - pgpm/env.lgt
      - pgpm/postgres.lgt
      - pgpm/fs.lgt
      - pgpm/path.lgt

    - Package Build & Management:
      - pgpm/build.lgt
      - pgpm/make_builder.lgt

    - Inference & Object Logic:
      - pgpm/inferences.lgt
      - pgpm/inherit_hook.lgt
      - pgpm/selectors.lgt

    - Origin & Protocol Handling:
      - pgpm/origin.lgt

PGPM Directory Structure

├── pgpm/
│   ├── requirements/
│   │   ├── c_compiler.lgt
│   │   ├── loader.Igt
│   │   ├── make.lgt
│   │   ├── pkgconfig.lgt
│   │   └── when.Igt
│   ├── build.Igt
│   ├── config.Igt
│   ├── env.lgt
│   ├── extended_relations.lgt
│   ├── fs.lgt
│   ├── git.lgt
│   ├── git_explicit_revision_package.lgt
│   ├── git_remote.lgt
│   ├── git_rev.lgt
│   ├── git_tagged_revision_package.Igt
│   ├── inferences.Igt
│   ├── inherit_hook.Igt
│   ├── loader.Igt
│   ├── make_builder.Igt
│   ├── metadata.lgt
│   ├── origin.Igt
│   ├── package.Igt
│   ├── path.Igt
│   ├── pgpm.Igt
│   ├── postgres.Igt
│   ├── requirement.Igt
│   ├── selectors.Igt
│   ├── tagged.Igt
│   └── version.Igt

pgpm Overview:

pgpm/build.lgt:

Defines protocols for building within the PGPM system. Sets up protocols and their associated predicates related to building.

  • protocol(builder): Defines the builder protocol.
  • public(build/0): Publicly accessible build function within the builder protocol.
  • protocol(buildable): Describes the buildable protocol.
  • public(builder/1): Public builder function within the buildable protocol.

pgpm/config.lgt:

Contains an object named config that manages configurations and metadata within PGPM.

  • set_hermetic_metadata/1: Sets hermetic metadata within the configuration.
  • hermetic_metadata/1: Retrieves the hermetic metadata.
  • set_hermetic/1 and hermetic/1: Functions to set and retrieve hermetic flags.
  • set_metadata/1 and metadata/1: Functions to set and retrieve metadata.

pgpm/env.lgt:

Defines an object env that handles environmental settings and determines the operating system and application paths within PGPM.

  • os/1: Identifies the operating system (Windows, MacOS, Unix, or Unknown).
  • available_executable/2: Checks the availability of an executable by name and provides its path.
  • application_cache_path/2: Constructs the application cache path based on the OS type.
  • home_dir/1: Retrieves the user's home directory.

pgpm/extended_relations.lgt:

Deals with extended relations in the PGPM system. It defines relations between different categories and entities.

  • includes_category/2: Checks if an entity includes a particular category.
  • Various rules are defined to determine category relationships, imports, and extensions within the PGPM system.

pgpm/fs.lgt:

Defines an object fs that handles file system-related operations.

  • recursive_directory_files/3: Recursively fetches files within a directory.
  • valid_filename/2: Checks and sanitizes a filename to ensure it contains valid characters.

pgpm/git_explicit_revision_package.lgt:

Defines a category for packages explicitly based on Git revisions.

  • It implements the package category and contains logic related to Git repositories and their revisions.
  • Predicates like origin/1 and version/1 retrieve origins and versions based on Git revisions.

pgpm/git_remote.lgt:

Handles Git remote repositories and tags.

  • git_remote_tag_exec/2: Executes Git commands to fetch remote tags from a repository.
  • git_remote object implements metadata_store and manages metadata related to Git URLs and their associated tags.
  • Predicates like tag/2 interact with remote repositories to retrieve tags for specific revisions.

pgpm/git_rev.lgt:

Defines an object git_rev that acts as an origin for Git repositories.

  • Predicates like repo/1, rev/1, tag/1, and commit/1 help in retrieving repository information, revisions, tags, and commits.
  • The downloaded/1 predicate seems to handle the process of downloading repositories based on specified revisions and storing them in a particular path within the cache.

pgpm/git_tagged_revision_package.lgt:

Defines a category named git_tagged_revision_package that implements the package category.

  • version/1: Derives the version from the provided argument or infers it from the Git tag.
  • origin/1: Retrieves Git repository information and the tag associated with a specific version.

pgpm/git.lgt:

Contains an object named git that deals with Git-related functionalities.

  • tag_version/2: Transforms a tag into a version by extracting and manipulating its characters.

pgpm/inferences.lgt:

Handles various inferences and metadata-related tasks for packages and their artifacts.

  • origin_artifacts object implements metadata_store and manages metadata like meta_json/2 and readme/2.
  • Categories like inferred_package_name, readme_inference, meta_json_inferences, c_compiler_requirement_inference, and more define inferences for package metadata, inferred package names, requirements, and buildable conditions.

pgpm/inherit_hook.lgt:

  • inherit_hook object: Implements the expanding protocol and performs term expansion for the :- inherit(F/A) directive.
    • It discontiguates the predicate F/A.
    • Generates expansion rules that check for category inheritance and dynamically create objects to accommodate inheritance chains.
    • Utilizes logtalk_load_context to identify the entity and the number of arguments in the term.

pgpm/loader.lgt:

  • Initialization for PGPM:
    • Loads various components necessary for PGPM functioning.
    • Specifies 'inherit_hook' as a hook for handling inheritance directives.

pgpm/make_builder.lgt:

  • make_builder object: Implements the builder protocol for the 'make' functionality.
    • process/2: Executes the build process by running 'make' with specific arguments generated based on the package's dependencies and requirements.
    • make_pgconfig_arg/1: Generates an argument related to 'pg_config'.
    • make_cc_arg/1: Generates an argument related to the C compiler.
    • make/1: Resolves the 'make' command based on package requirements.

pgpm/metadata.lgt:

  • metadata_store protocol:
    • Defines a protocol for handling metadata operations.
  • metadata object:
    • Stores facts related to metadata via fact/1 and record/1.
    • Provides functionality to save stored metadata to a file using save/1.

pgpm/origin.lgt:

  • origin protocol:
    • Defines the protocol for identifying the origin of entities or components.

pgpm/package.lgt:

  • Defines the package protocol with details like name, version, summary, description, origin, and readme.
  • Contains the definitions for objects and term expansions related to the package protocol.

pgpm/path.lgt:

  • Implements the origin protocol with a focus on identifying entities based on their file paths.

pgpm/pgpm.lgt:

package_hook Object:

Expansion handling for pgpm-related term expansions and object behaviors.

  • Key Functionalities:
    • merge_options/2: Merges various options for package definitions.
    • term_expansion/2: Performs term expansion related to packages, directories, basenames, and source attributes.

pgpm Object:

Core functionalities related to pgpm.

  • Key Functionalities:
    • load/1: Loads the PGPM system from the specified directory.
    • package/1: Validates a given package object to conform to the package protocol.
    • specific_package/1: Identifies a specific package with a defined origin.
    • latest_package/1: Fetches the latest version of a package or specific named package.

pgpm/postgres.lgt:

  • Contains an object for interacting with a PostgreSQL instance and identifying the path to pg_config.

pgpm/requirement.lgt:

  • Defines the protocols requirement_satisfier and requires along with the requirement object.

pgpm/selectors.lgt:

  • Category selectors related to filtering or selection operations, though the specific functionality isn't clear without detailed context.

pgpm/tagged.lgt:

  • Defines the tagged protocol to handle aspects related to tagging.

pgpm/version.lgt:

  • Manages version transformations and comparisons within the PGPM system.
  • Key Functionalities:
    • transform/1: Parses and transforms a given version to a semantic version format.
    • match/1: Compares different versions following Semantic Versioning (SemVer) guidelines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment