npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@onebeyond/agnostic-cms-harmonizer

v0.2.3

Published

Library to manage the communication with any CMS agnostic to the user

Downloads

386

Readme

Agnostic CMS Harmonizer

An agnostic library to handle communication with multiple CMS in an agnostic way.

NPM Version GitHub Release Date maintainability Socket

NPM Downloads all contributors LICENSE dependencies NPM Unpacked Size

Find the latest package version on the One Beyond NPM Registry

Quick Start

Install the library via npm:

npm i @onebeyond/agnostic-cms-harmonizer

Use the harmonized providers:

 import { ContentfulClient } from '@onebeyond/agnostic-cms-harmonizer';
 
 const client = new ContentfulClient({
   accessToken,
   space,
   environment,
 });

 await client.init();

 const entry = await client.getEntry<MyEntry>({ entryId: '123' });

 const collection = await client.getCollection<MyCollection>({ collectionId: '123' });

The library exposes a common interface for multiple CMSs and outputs harmonized data instead raw responses.

Each CMS provider exposes the getEntry and getCollection methods to request one or multiple entries accordingly.

First, supply the vendor-related configuration parameters to the constructor:

const cmsClient = new CmsClient(vendorConfigurationObject)

The client instance must call the init() method to configure the provider before attempting to request data from the CMS:

await client.init();

Now use the harmonizer methods of the cmsCLient.

 const entry = await client.getEntry<MyEntry>({ entryId: '123' });

 const collection = await client.getCollection<MyCollection>({ collectionId: '123' });

Enjoy!

Development

CLI

Install Contentful CLI or alternatively use npx contentful-cli

Environment Variables

  1. You have to create a space in contentful to run the tests.
  2. Follow the instructions here to create an API key.
  3. Setup your .env file as follows
CONTENTFUL_ACCESS_TOKEN=your_access_token
CONTENTFUL_ENVIRONMENT=your_environment
CONTENTFUL_SPACE=your_space
CONTENTFUL_ENTRY=your_entry
CONTENTFUL_CONTENT_TYPE=your_content_type

Testing

Import Content

To run the e2e tests you need to be authenticated in your contentful account and import the dummy content into the space you created before. The content you need to import is located at __tests__/exports/contentful/agnostic-cms-harmonizer_space.json and should not be updated.

Login to Contentful and import test content with the CLI:

contentful login

contentful space import --content-file __tests__/exports/contentful/agnostic-cms-harmonizer_space.json --space-id <your-contentful-space-id> --environment-id <your-contentful-environment-id>

Or by using NPX:

npx contentful-cli login

npx contentful-cli space import --content-file __tests__/exports/contentful/agnostic-cms-harmonizer_space.json --space-id <your-contentful-space-id> --environment-id <your-contentful-environment-id>

Export Content

To update the test content you need to export the updated content from Contentful.

Export the content using the CLI

contentful space export --config ./__tests__/exports/contentful/config.json --space-id <your-contentful-space-id> --environment-id <your-contentful-environment-id>

Or by using NPX:

npx contentful-cli space export --config ./__tests__/exports/contentful/config.json --space-id <your-contentful-space-id> --environment-id <your-contentful-environment-id>

Continous Integration

The pipeline is configured to use the Contentful space managed by the [email protected] account during the E2E tests execution. If the content of these tests needs to be updated in the provider, you must have access to this vault, otherwise, you can open an issue referencing the new content exported.

Run the test suites

  • Run unit tests
npm run test
  • Run end to end tests
npm run test:e2e

Documentation

The project uses tsdoc to generate the technical documentation from the source code.

  • Build the documentation
npm run docs:build
  • Run in watch mode to look for file changes and update immediately
npm run docs:build:watch
  • Serve the build output statically
npm run docs:serve

Community

  • We are open to improvements in the issues section.
  • Check the wiki for more context on the internal workings of this library.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!