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

trilium-pack

v0.1.1

Published

A simple way to pack addons as zip files for Trilium Notes.

Downloads

3

Readme

trilium-pack

A simple way to pack addons as zip files for Trilium Notes.

Note: This is still early in development and things may change rapidly. Use at your own discretion.

Install

npm install trilium-pack

Usage

CLI

To use this via cli (or npm scripts) you'll have to setup your config in either a tpack.json or tpack.config.json. In either case, trilium-pack will find the config and pack your addon.

Global

If you installed the package globally, just run tpack!

Local

Just add tpack to your npm scripts!

{
    "scripts": {
        "dist": "tpack"
    }
}

Node

const packAddon = require("trilium-pack");

// Replace with your config
const config = {};

// __dirname is the default so this is optional
const opts = {basePath: __dirname};

packAddon(config, opts);

Configuration

Currently, the configuration only has 2 top-level properties, output and notes, both are required.

| Name | Type | Description | |:----:|:----:|:------------| |output|string|A path to the desired output relative to the configuration file.| |notes|object|A tree of notes to be created with the root being a singular note.|

Notes

Each note can have several different properties, some of them optional, and some of them have defaults.

| Name | Type | Optional | Default | Description | |:----:|:----:|:--------:|:-------:|:------------| |file|string|❌*||Relative path string to the file to be included. *This may be omitted only for "render" notes.| |title|string|✅|filename|Title to be displayed in Trilium (affects pseudo-import name for scripts).| |type|string|✅|"code"|Type of note to be created. Only "code", "file" and "render" are currently supported due to the scope of this project.| |mime|string|✅|auto|Mime type to set for the note, this will be automatically determined from the file extension where possible.| |env|string|✅|"frontend"|Script environment for js notes. Should be either "frontend" or "backend".| |attributes|object|✅|{}|Attributes to be set on the imported note.| |children|Array<Note>|✅|filename|Title to be displayed in Trilium (affects pseudo-import name for scripts).|

Attributes

Due to the scope of the project, this does not support the full set of attribute features from Trilium such as inheritence. This only accepts a simple Record<string, string> set of attributes, where the key is the name of the attribute and the value is the value of the attribute. Every key can start with # or ~ to indicate label or relation type respectively. For relation notes, the value should be set to the target note.file string, abd it will be resolved automatically. For simple labels like #widget you can simply use an empty string "" as the value.

{
    "#widget": "",
    "#run": "frontendStartup",
    "~renderNote": "static/page.html",
}

Example

This example was tested with Trilium Heatmap.

tpack.config.js

module.exports = {
    output: "dist/Trilium-Heatmap.zip",
    notes: {
        title: "Trilium Heatmap",
        type: "render",
        attributes: {
            "~renderNote": "static/main.html"
        },
        children: [
            {
                file: "static/main.html",
                title: "HTML",
                children: [
                    {
                        file: "src/main.js",
                        env: "frontend",
                        children: [
                            {
                                title: "getDatas", // ensures import name
                                file: "scripts/getDatas.js",
                                attributes: {"#heatmapDatas": ""}
                            },
                            {
                                title: "setHistoryCount", // ensures import name
                                file: "scripts/setHistoryCount.js",
                                attributes: {"#run": "frontendStartup"}
                            },
                            {
                                file: "lib/d3.js",
                                title: "d3", // ensures import name
                                type: "file"
                            }
                        ]
                    }
                ]
            }
        ]
    }
};

More Info

Plans

  • Add more MIME types as needed
  • Add more options (e.g. enable/disable logging)

Known Limitations

  • Attributes don't support all attributes
  • Only 3 note types supported
  • Only a subset of MIME types supported