{"_id":"@codefocus/monosync","_rev":"2-8719ea4ef9dc7a73e0b0bb7fc56720c8","name":"@codefocus/monosync","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@codefocus/monosync","version":"0.1.0","keywords":["monorepo","package-sync","version-sync","workspace","package.json","synchronization","template","pnpm","npm","yarn","cli","developer-tools","build-tools"],"author":{"url":"https://codefocus.co.uk","name":"CodeFocus"},"license":"MIT","_id":"@codefocus/monosync@0.1.0","maintainers":[{"name":"codefocusuk","email":"codefocusdev@outlook.com"}],"homepage":"https://github.com/codefocusuk/monosync#readme","bugs":{"url":"https://github.com/codefocusuk/monosync/issues"},"bin":{"monosync":"dist/bin/sync-packages.js","sync-packages":"dist/bin/sync-packages.js","sync-versions":"dist/bin/sync-versions.js"},"dist":{"shasum":"d0509c08e02e0baf1784b3974f43758fc6920c38","tarball":"https://registry.npmjs.org/@codefocus/monosync/-/monosync-0.1.0.tgz","fileCount":16,"integrity":"sha512-Jpqp3sOcNWka0A/a/Xeq8+mPhqOlDmfXxUeLNZ0z94A12Y0fL71eoSA2WM77qgXUie8an+WDCUA/GfrqCaxHtw==","signatures":[{"sig":"MEUCIFs7zC/tF9r6Jwo1jPg+xd0YdwvuCpX6Xu1+gVYVhMaTAiEA6cv66LUxQhVHB4txqK54h7XSyFxaFrvwoCl2kgBRlqU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@codefocus%2fmonosync@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":46282},"main":"dist/lib/index.js","type":"module","types":"dist/lib/index.d.ts","engines":{"node":">=14.0.0"},"gitHead":"1de77004b49a33abd87f354206f3993bc122c136","scripts":{"dev":"tsc --watch","lint":"tsc --noEmit","test":"vitest --run --reporter=verbose","build":"tsc","prepack":"npm run build:tsc","build:tsc":"tsc","publish:dry":"npm publish --dry-run","publish:npm":"npm publish --access public","prepublishOnly":"npm run build"},"_npmUser":{"name":"codefocusuk","email":"codefocusdev@outlook.com"},"repository":{"url":"git+https://github.com/codefocusuk/monosync.git","type":"git"},"_npmVersion":"10.8.2","description":"Synchronize package.json files across monorepo workspaces with template-based configuration and version management","directories":{},"_nodeVersion":"20.19.6","_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.16","typescript":"^5.9.3","@types/node":"^25.0.3"},"_npmOperationalInternal":{"tmp":"tmp/monosync_0.1.0_1767111440422_0.07175682593181332","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@codefocus/monosync","version":"0.2.0","description":"Keep your monorepo package.json files consistent with automatic field ordering and version synchronization","type":"module","main":"dist/lib/index.js","types":"dist/lib/index.d.ts","bin":{"monosync":"dist/bin/sync-packages.js","sync-packages":"dist/bin/sync-packages.js","sync-versions":"dist/bin/sync-versions.js"},"scripts":{"build":"tsc","build:tsc":"tsc","dev":"tsc --watch","prepublishOnly":"npm run build","publish:npm":"npm publish --access public","publish:dry":"npm publish --dry-run","test":"vitest --run --reporter=verbose","lint":"tsc --noEmit","prepack":"npm run build:tsc"},"devDependencies":{"@types/node":"^25.0.3","typescript":"^5.9.3","vitest":"^4.0.16"},"keywords":["monorepo","package-sync","version-sync","workspace","package.json","synchronization","template","pnpm","npm","yarn","cli","developer-tools","build-tools"],"author":{"name":"CodeFocus","url":"https://codefocus.co.uk"},"license":"MIT","engines":{"node":">=14.0.0"},"homepage":"https://github.com/codefocusuk/monosync#readme","repository":{"type":"git","url":"git+https://github.com/codefocusuk/monosync.git"},"bugs":{"url":"https://github.com/codefocusuk/monosync/issues"},"_id":"@codefocus/monosync@0.2.0","gitHead":"c83c2b60bbc98d5120f357f02c223a01c75e0c4a","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-AWhZAJYOvXf7HA+MMYFagQtctOdmHnONM9eL5OVilferlxMyYbPjqlXNzw7tzJ01kgnt281QQxDA40pIjcqFXw==","shasum":"3778cadf740d06dc60a15d6043620cb056b57c1a","tarball":"https://registry.npmjs.org/@codefocus/monosync/-/monosync-0.2.0.tgz","fileCount":16,"unpackedSize":39107,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@codefocus%2fmonosync@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEwYJ9vSyCXKKXp9yR8lIRQF1GuXYTbNphX+CZDpEt1CAiEAhNjfHtMmmQ8UceTtSIOAwySqmjt/YBAaMe2FLKxpgL8="}]},"_npmUser":{"name":"codefocusuk","email":"codefocusdev@outlook.com"},"directories":{},"maintainers":[{"name":"codefocusuk","email":"codefocusdev@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/monosync_0.2.0_1767115289435_0.444378039322487"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-30T16:17:20.365Z","modified":"2025-12-30T17:21:29.988Z","0.1.0":"2025-12-30T16:17:20.578Z","0.2.0":"2025-12-30T17:21:29.608Z"},"bugs":{"url":"https://github.com/codefocusuk/monosync/issues"},"author":{"name":"CodeFocus","url":"https://codefocus.co.uk"},"license":"MIT","homepage":"https://github.com/codefocusuk/monosync#readme","keywords":["monorepo","package-sync","version-sync","workspace","package.json","synchronization","template","pnpm","npm","yarn","cli","developer-tools","build-tools"],"repository":{"type":"git","url":"git+https://github.com/codefocusuk/monosync.git"},"description":"Keep your monorepo package.json files consistent with automatic field ordering and version synchronization","maintainers":[{"name":"codefocusuk","email":"codefocusdev@outlook.com"}],"readme":"# @codefocus/monosync\n\n[![npm version](https://img.shields.io/npm/v/@codefocus/monosync.svg)](https://www.npmjs.com/package/@codefocus/monosync)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-%3E%3D14.0.0-green.svg)](https://nodejs.org/)\n\n**Keep your monorepo package.json files consistent with automatic field ordering and version synchronization**\n\nSimple, lightweight tools for maintaining consistency across monorepo packages.\n\n---\n\n## Why this exists\n\nManaging multiple packages in a monorepo leads to inconsistency:\n\n- **Inconsistent field ordering** — Different packages have fields in different orders\n- **Version drift** — Keeping package versions synchronized manually is tedious\n- **Manual maintenance** — Updating common fields across packages is error-prone\n\n`@codefocus/monosync` solves these problems by:\n\n- **Auto-discovering packages** — No configuration needed, works with pnpm/yarn/npm workspaces\n- **Preserving all values** — Never overwrites your package.json content\n- **Reordering fields** — Maintains consistent field order across all packages\n- **Syncing versions** — One command to align all package versions\n- **Zero dependencies** — Lightweight and fast\n- **TypeScript + CLI** — Use as a library or command-line tool\n\n---\n\n## Installation\n\nInstall as a dev dependency in your monorepo root:\n\n```bash\nnpm install -D @codefocus/monosync\n# or\nyarn add -D @codefocus/monosync\n# or\npnpm add -D @codefocus/monosync\n```\n\nAdd scripts to your root `package.json`:\n\n```json\n{\n  \"scripts\": {\n    \"sync\": \"sync-packages && sync-versions\"\n  }\n}\n```\n\n---\n\n## Quick Start\n\nThat's it! Just run:\n\n```bash\nnpm run sync\n```\n\nThis will:\n1. Auto-discover all packages in your monorepo\n2. Reorder package.json fields to a consistent order\n3. Synchronize all package versions with the root version\n\n**No configuration files needed.**\n\n---\n\n## What It Does\n\n### sync-packages\n\n**Reorders package.json fields** to maintain consistency across your monorepo.\n\n- Auto-discovers packages from `pnpm-workspace.yaml` or scans standard directories (`packages/`, `apps/`, `libs/`)\n- Reads each package.json and **preserves all values**\n- Reorders fields to a standard order:\n  - `name`, `version`, `private`, `type`, `license`, `description`\n  - `main`, `module`, `types`\n  - `repository`, `homepage`, `bugs`, `author`, `contributors`\n  - `keywords`, `funding`, `engines`\n  - `exports`, `files`, `scripts`\n  - `dependencies`, `devDependencies`, `peerDependencies`, `peerDependenciesMeta`\n- Writes back with consistent formatting (2-space indentation, trailing newline)\n\n**Important:** This tool does NOT modify your values - it only reorders fields for consistency.\n\n### sync-versions\n\n**Synchronizes package versions** across your monorepo.\n\n- Recursively finds all package.json files\n- Reads version from root package.json\n- Updates all child package versions\n- Reports which packages changed\n\n---\n\n## Optional: Template for Common Fields\n\nYou can optionally provide a template to add missing common fields (like `repository`, `author`, `engines`):\n\nCreate `.monosync/package-template.json`:\n\n```json\n{\n  \"license\": \"MIT\",\n  \"author\": {\n    \"name\": \"Your Name\",\n    \"url\": \"https://yoursite.com\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/yourorg/yourrepo.git\"\n  },\n  \"engines\": {\n    \"node\": \">=18.0.0\"\n  }\n}\n```\n\nNow `sync-packages` will:\n1. Reorder all fields\n2. Add missing common fields from the template (without overwriting existing values)\n\nThe template is **completely optional** - sync-packages works fine without it.\n\n---\n\n## CLI Usage\n\n### sync-packages\n\n```bash\n# Auto-discover and reorder all package.json files\nsync-packages\n\n# Use a template for adding missing common fields\nsync-packages --template .monosync/package-template.json\n\n# Show help\nsync-packages --help\n```\n\n**Options:**\n- `--template <path>` - Path to package-template.json (optional)\n- `-h, --help` - Show help message\n- `-v, --version` - Show version number\n\n### sync-versions\n\n```bash\n# Sync versions from root package.json\nsync-versions\n\n# Use a specific version\nsync-versions --version 1.2.3\n\n# Show help\nsync-versions --help\n```\n\n---\n\n## Programmatic Usage\n\nUse as a library in your build scripts:\n\n```typescript\nimport { syncPackages, syncVersions } from '@codefocus/monosync';\n\n// Reorder package.json fields (auto-discovers packages)\nconst results = syncPackages(process.cwd());\n\n// Reorder and add missing common fields from template\nconst resultsWithTemplate = syncPackages(process.cwd(), {\n  templatePath: '.monosync/package-template.json',\n});\n\n// Synchronize versions\nconst versionResults = syncVersions(process.cwd(), {\n  targetVersion: '2.0.0', // optional\n});\n```\n\n### API Reference\n\n#### syncPackages(rootDir, options?)\n\nReorders package.json fields across your monorepo.\n\n**Parameters:**\n- `rootDir` (string) — Path to monorepo root\n- `options` (object, optional)\n  - `templatePath` (string) — Path to template for adding missing common fields\n\n**Returns:** `SyncResult[]`\n\n#### syncVersions(rootDir, options?)\n\nSynchronizes package versions across the monorepo.\n\n**Parameters:**\n- `rootDir` (string) — Path to monorepo root\n- `options` (object, optional)\n  - `targetVersion` (string) — Use this version instead of root package.json\n  - `verbose` (boolean) — Enable verbose logging\n\n**Returns:** `VersionSyncResult[]`\n\n---\n\n## How It Works\n\n### sync-packages\n\n1. **Auto-discover** — Reads `pnpm-workspace.yaml` or scans `packages/`, `apps/`, `libs/` directories\n2. **Read** — Loads each package.json\n3. **Reorder** — Reorders fields to standard order\n4. **Add template fields** (optional) — Adds missing common fields from template if provided\n5. **Write** — Writes formatted package.json back to disk\n6. **Report** — Shows success/failure summary\n\n### sync-versions\n\n1. **Scan** — Recursively finds all package.json files\n2. **Filter** — Excludes node_modules and root package.json\n3. **Read** — Gets target version from root or command line\n4. **Update** — Updates version field in each package.json\n5. **Report** — Shows which packages changed\n\n---\n\n## Comparison with Alternatives\n\n### Manual updates\n- ❌ Tedious and error-prone\n- ❌ Easy to miss packages\n- ❌ Inconsistent field ordering\n\n### Massive config files\n- ❌ Duplicate all package.json content\n- ❌ Maintain two sources of truth\n- ❌ Values get out of sync\n\n### @codefocus/monosync\n- ✅ Zero configuration required\n- ✅ Auto-discovers packages\n- ✅ Preserves all values\n- ✅ Only reorders fields for consistency\n- ✅ Optional template for missing fields\n- ✅ TypeScript support\n\n### Workspace protocols (pnpm/yarn/npm)\n- These handle dependency management\n- monosync handles consistency and version synchronization\n- Use both together for complete monorepo management\n\n---\n\n## Who is this for?\n\n- Teams maintaining monorepos with multiple packages\n- Projects using pnpm/yarn/npm workspaces\n- Anyone wanting consistent package.json formatting\n- CI/CD pipelines that need synchronized versions\n- Projects that want automation without complex configuration\n\n---\n\n## Development\n\n### Setup\n\n```bash\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n\n# Watch mode for development\nnpm run dev\n\n# Run tests\nnpm test\n```\n\n### Project Structure\n\n```\nsrc/\n├── bin/\n│   ├── sync-packages.ts    # CLI for package sync\n│   └── sync-versions.ts    # CLI for version sync\n└── lib/\n    ├── sync-packages.ts    # Package sync logic\n    ├── sync-versions.ts    # Version sync logic\n    ├── types.ts            # TypeScript definitions\n    └── index.ts            # Public API exports\n```\n\n---\n\n## Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes with tests\n4. Submit a pull request\n\n---\n\n## Changelog\n\n### v0.2.0\n\n**BREAKING CHANGES:**\n- Completely redesigned `sync-packages` to only reorder fields (no longer requires package-configs.json)\n- Auto-discovers packages from workspace configuration\n- Template is now optional and only adds missing common fields\n- Removed `validate` command and complex configuration options\n\n**Migration from v0.1.x:**\n- Remove `package-configs.json` (no longer needed)\n- Keep `package-template.json` if you want to add missing common fields (now optional)\n- Update scripts: `sync-packages` now auto-discovers packages\n\n### v0.1.0\n\n- Initial release with template-based package synchronization\n\n---\n\n## License\n\nMIT © [CodeFocus](https://codefocus.co.uk)\n\n---\n\n## Support\n\n- [Documentation](https://github.com/codefocusuk/monosync#readme)\n- [Issue Tracker](https://github.com/codefocusuk/monosync/issues)\n- [npm Package](https://www.npmjs.com/package/@codefocus/monosync)\n","readmeFilename":"README.md"}