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

yproject_policy

v1.4.1

Published

Local package manager. A tool to manage your multi-repo.

Downloads

592

Readme

yproject_policy

When you have many projects, it's usually convenient to have same "config" for all of them. This package lets you define policies, than verify and apply them to multiple projects.

Policies usually include:

  • Code formatting rules
  • Linting rules
  • Test tools
  • Compilation config
  • Folder layouts
  • ...etc
What is multi-repo? Why not mono repo?

All the above is specifically interesting if you use multi-repo approach, perhaps with ymultirepo package.

This article describes why that's better: https://medium.com/@PepsRyuu/monorepos-in-javascript-anti-pattern-917603da59c8

Installation

  1. Projects that consume local modules should have yproject_policy installed to node_modules. So
  • pnpm i -g yproject_policy AND set NODE_PATH to global modules folder (recommended). You can use the following snippet to set NODE_PATH permanently on Windows:
pnpm config get prefix > node_path.txt
setx /m /p NODE_PATH= < node_path.txt
setx NODE_PATH %NODE_PATH% /m
erase node_path.txt
  • OR
  • Just use pnpm i yproject_policy --saveDev in each consumer
  1. Use pnpm config to set local_packages_folder to the folder where you store your projects:

     pnpm config set local_packages_folder YOUR_PATH_TO_PROJECTS_FOLDER
  2. Use pnpm config to set diff_editor to specify the path to your text editor, to display the difference in file contents:

     pnpm config set diff_editor YOUR_PATH_TO_TEXT_EDITOR

Usage

Defining a policy

  1. Make a separate git repository for new policy.

  2. Place all the files you want to enforce into it.

  3. Add yproject_policy_definition.cjs to the root of your project. This file should contain:

    module.exports.policy = "POLICY_NAME";
    module.exports.options = {
     exclude: [] // exclude specified folders and files from projects
     // policy options here
    }
  4. If some files should be generated - make a FILENAME.gen.cjs . This file should contain:

    module.exports.generate = function generate(packageJson, policyOptions) {
        return `GENERATED FILE CONTENTS`;
    }
  5. Optionally you can create rules.cjs to define additional rules in it

Appling policy to a project

  1. Add yproject_policy.cjs to the root of your project. This file should contain:

    module.exports.policy = "POLICY_NAME";
    module.exports.options = {
     exclude: [] // ignore specified directories and files during policy enforcement
     // policy options here
    }
  2. Now yproject_policy - will check this project with specified the policy. It will interactivelly ask what should it do with each policy violation

  3. Now yproject_policy -a - will check all your projects in "local_packages_folder" (see Installation step).

Uninstallation

If you didn't liked yproject_policy uninstallation process is quite simple.

  • pnpm uninstall -g yproject_policy (or pnpm uninstall yproject_policy if you installed it locally)
  • delete yproject_policy.cjs file in your projects

Functions (Developer guide)