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

@maksimert/symlink-generator

v1.0.3

Published

Magically making symlinks for devops usage

Downloads

5

Readme

Symlink generator for Maksimers usage in hosting

This tool is responsible for reading a json file containing symlink definitions in a project.

The tool is ran with the command:

npx @maksimert/symlink-generator -releasenum=SOME_NUMBER

or with the -y included (for newer node versions):

npx -y @maksimert/symlink-generator -releasenum=SOME_NUMBER

There is no need to install it to the project package.json etc.

Custom Server Root (dev server etc.)

In the symlinks.json you define one serverRoot, this would be your regular, probably production server root. If you in the same repository also have a pipeline going to another server, another root etc, this script can receive another argument named serverRoot

Example: npx -y @maksimert/symlink-generator -releasenum=SOME_NUMBER -serverRoot="/home/someuser/sites/somesite"

The symlinks.json file

To run this tool, there needs to be a symlinks.json file present in the directory you run the tool from.

This file has support for 5 different "types" of symlinks. The types are mostly there to help with what paths to select.

Server root

Here you define the path on the server that equals to the path of your repository. Usually the directory where you find wp-config.php

If your repository is structured like this: htdocs/wp-content..etc you find the location on the server where you can see the htdocs folder.

This is usually at: /home/USERNAME/sites/someurl.no/

The serverRoot definition should look like this:

"serverRoot": "/home/USERNAME/sites/someurl.no",

Type: plugins

Plugins is defined as the foldername of the plugin you want to be synced. If your repository contains a plugin with foldername "my-cool-woocommerce-plugin" you enter exactly that in the array of plugins:

"plugins": [
  "my-cool-woocommerce-plugin"
],

If you also have a plugin with foldername "my-plugin-is-way-cooler", you add a new line, making the resulting plugins definition look like this:

"plugins": [
  "my-cool-woocommerce-plugin",
  "my-plugin-is-way-cooler"
],

Type: themes

This works in the exact same way as plugins. If you have a theme with the foldername "awesome-theme", the themes config should look like this:

"themes": [
  "awesome-theme"
],

Type languagePlugin

If you have language files for third party plugins, you add them here.

If the language was Norwegian and the plugin textdomain was "wowiwow" the language files probably has these names:

wowiwow-nb_NO.po and wowiwow-nb_NO.mo

The languagePlugins definition should then look like this:

"languagePlugins": [
  "wowiwow-nb_NO.po",
  "wowiwow-nb_NO.mo"
],

Type languageTheme

This is exactly as the languagePlugin definition, the only difference is what language folder we use for symlinking.

Norwegian language and text domain "best-theme" ends up as:

"languageThemes": [
  "best-theme-nb_NO.po",
  "best-theme-nb_NO.mo",
],

Type files

Here is where things change up a bit. We don't help you with the path for files (We will always start at the repository root folder).

Let's say you have the following files that needs to be symlinked:

htdocs/wp-content/best-file-ever.php and somerandomfolder/somerandomfile.php

The definition looks like this:

"files": [
  {
    "subDirectory": "htdocs/wp-content",
    "fileName": "best-file-ever.php"
  },
  {
    "subDirectory": "somerandomfolder",
    "fileName": "somerandomfile.php"
  }
]

It's best to not include a trailing / You should NOT include a starting /

What happens when this runs?

When this script runs, it goes trough the defined plugins, themes, languages and single files.

It appends some base path to the start of every definition, both for the path in the repository and for the path on the server.

Take plugins as an example.

Your repository is structured like this: htdocs/wp-content/plugins/myplugin

The server root is: /home/coolname/sites/somesite.no

The pipeline you're running is number 13

The tool will create the following symlink command:

ln -sfn /home/coolname/sites/somesite.no/releases/13/htdocs/wp-content/plugins/myplugin /home/coolname/sites/somesite.no/htdocs/wp-content/plugins/myplugin

All that text, and all you did was enter: "myplugin" :)