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

cosmere

v0.17.2

Published

Sync your markdown files to confluence.

Downloads

2,222

Readme

Cosmere

Sync your markdown files to confluence.

Features

  • upload new versions only when necessary
  • upload/delete local images as attachments
  • supports the original markdown spec and parts from CommonMark and GitHub Flavored Markdown
  • can be used as a CLI command or in a script

Usage

Global Installation

npm install -g cosmere

# or

yarn global add cosmere

Library

npm install --save-dev cosmere

# or

yarn add --dev cosmere

Configuration

To get started generate configuration using

cosmere generate-config [--config=<path>]

which produces:

{
    "baseUrl": "<your base url including /rest/api>",
    "user": "<your username>",
    "pass": "<your password>",
    "personalAccessToken": "<your personal access token (can be set instead of username/password)>",
    "cachePath": "build",
    "prefix": "This document is automatically generated. Please don't edit it directly!",
    "pages": [
        {
            "pageId": "1234567890",
            "file": "README.md",
            "title": "Optional title in the confluence page, remove to use # h1 from markdown file instead"
        }
    ]
}

Continuous Integration

In most scenarios it is not recommended storing your credentials in the configuration file, because you will probably add it to your VCS. Instead, it is recommended to provide the following environment variables in your build pipeline (GitLab CI, GitHub Actions, Jenkins, ...):

CONFLUENCE_USERNAME=YOUR_USERNAME
CONFLUENCE_PASSWORD=YOUR_PASSWORD

or

CONFLUENCE_PERSONAL_ACCESS_TOKEN="<your auth token>"

or add it in front of the command when executing locally (add a space in front of the command when using bash in order to not write the credentials to the bash history):

 CONFLUENCE_USER=YOUR_USERNAME CONFLUENCE_PASSWORD=YOUR_PASSWORD cosmere
 # or
 CONFLUENCE_PERSONAL_ACCESS_TOKEN="<your personal access token>" cosmere

Run

# global installation
cosmere --help

# local installation with yarn
yarn cosmere --hhelp

# local installation with npm
npm run cosmere --help

# or plain
node_modules/.bin/cosmere --help

or create an alias:

{
    "scripts": {
        "pushdoc": "cosmere"
    }
}

Using Cosmere as a library

import cosmere from "cosmere/dist/src/lib";
import ConfluenceRenderer from "cosmere/dist/src/ConfluenceRenderer";

class CustomRenderer extends ConfluenceRenderer {
    constructor(options, config, page) {
        super(options, config, page);
    }

    image(href, title, text) {
        if (href.startsWith("http")) {
            return `<ac:image ac:width="768px" ac:height="768px"><ri:url ri:value="${href}" /></ac:image>`;
        }
        return `<ac:image ac:width="768px" ac:height="768px"><ri:attachment ri:filename="${href}" /></ac:image>`;
    }
}

const config = {
    baseUrl: "<your base url including /rest/api>",
    user: "<your username>",
    pass: "<your password>",
    cachePath: "build",
    prefix: "This document is automatically generated. Please don't edit it directly!",
    insecure: false,
    force: false,
    fileRoot: "/usr/bin/myawesomefolder",
    pages: [
        {
            pageId: "1234567890",
            file: "README.md", // this path will be evaluated as fileRoot + file
            title: "Optional title in the confluence page, remove to use # h1 from markdown file instead",
        },
    ],
    customRenderer: CustomRenderer,
};

await cosmere(config);

Troubleshooting

Custom certificates on Confluence instance

Use the --insecure option for your cosmere call in order to not reject invalid certificates. This is risky, and it's preferable to get proper certificates.

Need new features?

Please, feel free to create any issues and pull request that you need.

Release

  1. Add feature/fix bugs etc.
  2. Document changes in CHANGELOG.md (with the new version)
  3. Commit everything
  4. Push/merge to main
  5. Run
    yarn release
    yarn np <major|minor|patch>

History

md2confluence

I had various scripts that stitched markdown files together and uploaded them. I forked md2confluence by Jormar Arellano and started playing around with that, but quickly noticed that many markdown files broke due to the conversion process (wiki -> storage instead of directly to storage).

Cosmere

The project diverged from its original intent and so I decided to rename it. Cosmere is the wonderful universe of various books written by Brandon Sanderson. If you are into fantasy I strongly recommend checking him out.

License

See LICENSE.