Skip to content

sxzz/monoman

Repository files navigation

monoman npm

Unit Test

Manage monorepo common files.

Install

npm i monoman

Usage

pnpm monoman [-c | --check | -w | --write]
// monoman.config.[ts,js]
import { defineConfig } from 'monoman'

export default defineConfig([
  {
    // Globs to match files
    include: ['**/package.json'],
    exclude: ['exclude/package.json'],
    type: 'json',
    contents(data: Record<string, string>) {
      data.name = 'monoman'
      return data
    },
  },
  {
    include: ['**/package.json'],
    exclude: ['exclude/package.json'],
    type: 'text',
    contents(text) {
      return `${text} hello monoman!`
    },
  },
  {
    include = 'pnpm-lock.yaml',
    exclude: ['exclude/pnpm-lock.yaml'],
    type: 'yaml',
    contents(data: Record<string, string>) {
      data.lockfileVersion = '9.0'
      return data
    },
  },
])

See an example for more details.

Presets

noDuplicatedDeps

Make all dependencies in all package.json unique.

function noDuplicatedDeps({
  include = 'packages/*/package.json',
  exclude,
  distinguishType = false,
  types = ['dependencies', 'devDependencies'],
  ignoreProtocols = ['file', 'link', 'workspace'],
}: {
  include?: Arrayable<string>
  exclude?: Arrayable<string>
  distinguishType?: boolean
  types?: string[]
  ignoreProtocols?: string[]
} = {})

`noDuplicatedPnpmLockfile

function noDuplicatedPnpmLockfile({
  include = 'pnpm-lock.yaml',
  exclude,
  deps = [],
}: {
  /** Include files */
  include?: Arrayable<string>
  /** Exclude files */
  exclude?: Arrayable<string>
  /** Deps to check */
  deps?: Arrayable<string>
} = {})

Sponsors

License

MIT License © 2023 三咲智子