Convert Figma logo to code with AI

sapegin logomrm

Codemods for your project config files

1,607
77
1,607
10

Top Related Projects

49,046

Prettier is an opinionated code formatter.

32,324

Git hooks made easy 🐶 woof!

🚫💩 — Run linters on git staged files

📓 Lint commit messages

⚡ Get Pretty Quick

10,976

A mighty CSS linter that helps you avoid errors and enforce conventions.

Quick Overview

Mrm (Magnetic Resource Manager) is a command-line tool to help you keep configuration files in sync across multiple projects. It automates the process of creating and updating various config files like package.json, .gitignore, and more. Mrm can be extended with custom tasks and presets to fit your specific needs.

Pros

  • Saves time by automating the creation and updating of config files
  • Highly customizable with user-defined tasks and presets
  • Supports a wide range of popular config files out of the box
  • Can be used to enforce consistent configurations across multiple projects

Cons

  • Requires initial setup and learning curve to create custom tasks
  • May not cover all possible configuration scenarios
  • Potential for conflicts if used alongside other config management tools
  • Limited documentation for advanced use cases

Code Examples

  1. Running a built-in task:
npx mrm license

This command runs the built-in "license" task to add or update the license file in your project.

  1. Creating a custom task:
// mrm-task-mylint.js
const { json, packageJson } = require('mrm-core');

module.exports = function task() {
  json('.eslintrc.json')
    .merge({
      extends: ['eslint:recommended', 'plugin:react/recommended'],
    })
    .save();

  packageJson()
    .setScript('lint', 'eslint . --ext .js,.jsx')
    .save();
};

This custom task adds ESLint configuration and a lint script to your project.

  1. Running multiple tasks:
npx mrm license readme eslint

This command runs multiple built-in tasks in sequence to set up license, readme, and ESLint configuration.

Getting Started

To get started with Mrm, follow these steps:

  1. Install Mrm globally:
npm install -g mrm
  1. Run a built-in task:
mrm license
  1. Create a custom task (e.g., mrm-task-custom.js) in your project directory:
module.exports = function task() {
  // Your custom task logic here
};
  1. Run your custom task:
mrm custom

For more advanced usage and configuration options, refer to the official Mrm documentation.

Competitor Comparisons

49,046

Prettier is an opinionated code formatter.

Pros of Prettier

  • Widely adopted and supported by the community
  • Opinionated formatting with minimal configuration needed
  • Supports a broad range of languages and file types

Cons of Prettier

  • Less flexible for custom formatting rules
  • Can be slower for large codebases due to its comprehensive approach
  • May require additional setup for integration with other tools

Code Comparison

Prettier configuration (.prettierrc):

{
  "semi": false,
  "singleQuote": true,
  "trailingComma": "es5"
}

Mrm task for Prettier setup:

module.exports = function task({ config }) {
  // Install prettier
  // Add .prettierrc
  // Update package.json scripts
}

Key Differences

  • Prettier focuses solely on code formatting, while Mrm is a configuration management tool that can set up various development tools, including Prettier
  • Prettier is language-specific and provides automatic formatting, whereas Mrm is language-agnostic and helps manage project configurations
  • Mrm allows for more customization in how tools are set up, while Prettier aims for consistency with minimal configuration

Use Cases

  • Use Prettier for enforcing consistent code style across a project or team
  • Use Mrm for automating the setup and maintenance of various development tools and configurations in a project
32,324

Git hooks made easy 🐶 woof!

Pros of Husky

  • Simpler setup and configuration process
  • Focuses specifically on Git hooks, making it more lightweight
  • Widely adopted in the JavaScript community with strong ecosystem support

Cons of Husky

  • Limited to Git hooks management only
  • Less flexibility for managing other project configuration tasks
  • Requires manual setup for each new project

Code Comparison

Husky configuration (package.json):

{
  "husky": {
    "hooks": {
      "pre-commit": "npm test",
      "pre-push": "npm run lint"
    }
  }
}

Mrm task configuration:

module.exports = function task() {
  // Install husky
  install('husky');
  
  // Add Git hooks
  packageJson().merge({
    husky: {
      hooks: {
        'pre-commit': 'npm test',
        'pre-push': 'npm run lint'
      }
    }
  });
};

Mrm offers a more programmatic approach to configuring Husky and other project settings, while Husky provides a simpler, more focused solution for Git hooks management. Mrm allows for greater customization and automation of project setup tasks, but may have a steeper learning curve compared to Husky's straightforward configuration.

🚫💩 — Run linters on git staged files

Pros of lint-staged

  • Focuses specifically on running linters and other checks on staged files
  • Integrates seamlessly with Git hooks, particularly pre-commit
  • Supports a wide range of linters and formatters out of the box

Cons of lint-staged

  • Limited to pre-commit operations and file-specific tasks
  • Requires manual configuration for each project
  • Less flexibility for managing other aspects of project configuration

Code Comparison

lint-staged configuration:

{
  "lint-staged": {
    "*.js": "eslint --fix",
    "*.{js,css,md}": "prettier --write"
  }
}

mrm task for adding lint-staged:

module.exports = function task() {
  // Install dependencies
  pkg.appendScript('lint-staged', 'lint-staged');
  pkg.save();

  // Create lint-staged config
  lines('.lintstagedrc')
    .add({
      '*.js': ['eslint --fix', 'git add'],
      '*.{js,css,md}': ['prettier --write', 'git add'],
    })
    .save();
};

While lint-staged excels at running linters on staged files, mrm provides a more comprehensive approach to managing project configuration, including the setup of lint-staged itself. lint-staged is more focused and easier to use for its specific purpose, while mrm offers greater flexibility for overall project maintenance.

📓 Lint commit messages

Pros of commitlint

  • Focused specifically on enforcing commit message conventions
  • Integrates well with Husky for pre-commit hooks
  • Extensive configuration options for custom commit message rules

Cons of commitlint

  • Limited to commit message linting, doesn't handle other project maintenance tasks
  • Requires additional setup and configuration for full functionality
  • May be overkill for smaller projects or teams with established commit practices

Code Comparison

commitlint configuration example:

{
  "extends": ["@commitlint/config-conventional"],
  "rules": {
    "type-enum": [2, "always", ["feat", "fix", "docs", "style", "refactor", "test", "chore"]]
  }
}

mrm task example:

module.exports = function task() {
  // Update package.json
  pkg()
    .setScript('lint', 'eslint . --cache --fix')
    .save();

  // Install dependencies
  install('eslint');
};

Summary

commitlint is a specialized tool for enforcing commit message conventions, offering deep customization for commit linting. It works well with other tools like Husky but focuses solely on commit messages. mrm, on the other hand, is a more versatile project maintenance tool that can handle various tasks beyond commit linting, including file generation and dependency management. The choice between the two depends on the specific needs of the project and the desired level of commit message enforcement.

⚡ Get Pretty Quick

Pros of Pretty-Quick

  • Focused specifically on running Prettier quickly and efficiently
  • Integrates seamlessly with Git, only formatting changed files
  • Lightweight and easy to set up with minimal configuration

Cons of Pretty-Quick

  • Limited to Prettier formatting, lacks broader project management features
  • Doesn't handle configuration management or other development tools
  • Less flexibility for customizing project structures and workflows

Code Comparison

Pretty-Quick:

const prettyQuick = require('pretty-quick');

prettyQuick({
  staged: true,
  pattern: ['**/*.js', '**/*.jsx']
});

Mrm:

const { json, install } = require('mrm-core');

module.exports = function task() {
  json('.prettierrc')
    .merge({ singleQuote: true, trailingComma: 'es5' })
    .save();
  install('prettier');
};

Summary

Pretty-Quick excels at quickly running Prettier on changed files, making it ideal for pre-commit hooks and CI/CD pipelines. It's simple to use but limited in scope. Mrm, on the other hand, offers a more comprehensive approach to project configuration management, including Prettier setup among other tools. Mrm provides greater flexibility and customization options but may require more setup and configuration for specific tasks like running Prettier efficiently on changed files.

10,976

A mighty CSS linter that helps you avoid errors and enforce conventions.

Pros of stylelint

  • Specialized for CSS linting with extensive rule set
  • Large community and ecosystem of plugins
  • Integrates well with various build tools and editors

Cons of stylelint

  • Limited to CSS-related tasks
  • Steeper learning curve for configuration
  • Can be resource-intensive for large projects

Code Comparison

stylelint configuration example:

{
  "extends": "stylelint-config-standard",
  "rules": {
    "indentation": 2,
    "color-hex-case": "lower"
  }
}

mrm task example:

module.exports = function task() {
  // Update package.json
  pkg().merge({
    scripts: {
      lint: 'stylelint "**/*.css"'
    }
  }).save();
};

While stylelint focuses on CSS linting with a comprehensive ruleset, mrm is a more general-purpose tool for managing project configuration files. stylelint provides deep CSS-specific functionality, whereas mrm offers broader project setup capabilities across various tools and languages. The choice between them depends on whether you need specialized CSS linting or more general project configuration management.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Mrm

npm Codecov Node.js CI status

Command line tool to help you keep configuration (package.json, .gitignore, .eslintrc, etc.) of your open source projects in sync.

Features

  • Doesn’t overwrite your data unless you want to
  • Minimal changes: keeps the original file formatting or read the style from EditorConfig
  • Minimal configuration: tries to infer configuration from the project itself or from the environment
  • Customizable tasks for popular tools like ESLint, Prettier, lint-staged, etc. included
  • Custom tasks and tools to work with JSON, YAML, INI, Markdown and new line separated text files
  • Sharing tasks via npm and grouping them into presets

Motivation

Most of the available tools are template based. Template approach works moderately well for new project generation but doesn’t work well for updating. Mrm’s approach is closer to codemods than templates.

Read more in my article, Automating open source project configuration with Mrm, or watch my talk on Mrm.

Documentation

Tasks

These tasks are included by default:

Changelog

The changelog can be found on the Releases page.

Sponsoring

This software has been developed with lots of coffee, buy me one more cup to keep it going.

Buy Me A Coffee

Contributing

Bug fixes are welcome, but not new features. Please take a moment to review the contributing guidelines.

Authors and license

Artem Sapegin and contributors.

MIT License, see the included License.md file.

NPM DownloadsLast 30 Days