Manage monorepo common files.
npm i monoman
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.
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[]
} = {})
function noDuplicatedPnpmLockfile({
include = 'pnpm-lock.yaml',
exclude,
deps = [],
}: {
/** Include files */
include?: Arrayable<string>
/** Exclude files */
exclude?: Arrayable<string>
/** Deps to check */
deps?: Arrayable<string>
} = {})