{"id":18888380,"url":"https://github.com/pnpm/meta-updater","last_synced_at":"2025-04-13T06:32:46.111Z","repository":{"id":55525798,"uuid":"326454323","full_name":"pnpm/meta-updater","owner":"pnpm","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-02T02:05:32.000Z","size":417,"stargazers_count":56,"open_issues_count":5,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T02:30:31.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pnpm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-03T16:46:15.000Z","updated_at":"2025-03-02T02:05:13.000Z","dependencies_parsed_at":"2024-05-01T17:21:13.407Z","dependency_job_id":"7a511e64-a410-4682-8a0e-492ad833d0fb","html_url":"https://github.com/pnpm/meta-updater","commit_stats":{"total_commits":45,"total_committers":5,"mean_commits":9.0,"dds":0.0888888888888889,"last_synced_commit":"7a0a6bc5d9310bf48f9bf4cb4e342661bfe07cba"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnpm%2Fmeta-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnpm%2Fmeta-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnpm%2Fmeta-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnpm%2Fmeta-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pnpm","download_url":"https://codeload.github.com/pnpm/meta-updater/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674658,"owners_count":21143760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T07:43:46.243Z","updated_at":"2025-04-13T06:32:46.036Z","avatar_url":"https://github.com/pnpm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @pnpm/meta-updater\n\n\u003e Keeps meta files up-to-date in a monorepo\n\n[![npm version](https://img.shields.io/npm/v/@pnpm/meta-updater.svg)](https://www.npmjs.com/package/@pnpm/meta-updater)\n\n## Installation\n\n```sh\n\u003cpnpm|yarn|npm\u003e add @pnpm/meta-updater\n```\n\n## Usage\n\nCreate a JavaScript file at `.meta-updater/main.mjs` that contains the updater functions.\n\n## Example 1\n\nThe following `.meta-updater/main.mjs` defines updaters for `package.json` and `tsconfig.json` files:\n\n```js\nexport default (workspaceDir) =\u003e {\n  return {\n    'package.json': (manifest, dir) =\u003e {\n      return {\n        ...manifest,\n        author: 'Foo Bar',\n      }\n    },\n    'tsconfig.json': (tsConfig, dir) =\u003e {\n      return {\n        ...tsConfig,\n        compilerOptions: {\n          outDir: 'lib',\n          rootDir: 'src',\n        },\n      }\n    },\n  }\n}\n```\n\n### Example 2\n\nThe following `.meta-updater/main.mjs` defines format `#ignore` and updaters for `.gitignore` and `.eslintrc` using explicit format specifier.\n\n```js\nimport * as fs from 'fs/promises'\nimport { createFormat, createUpdateOptions } from '@pnpm/meta-updater'\n\n/* default .eslintrc */\nexport const eslintrc = {}\n\n/* default tsconfig.json */\nexport const tsconfig = { compilerOptions: { target: 'esnext' } }\n\n/**\n * User-defined format '#ignore'\n */\nconst ignoreFormat = createFormat({\n  async read({ resolvedPath }) {\n    return (await fs.readFile(resolvedPath, 'utf8')).split('\\n')\n  },\n  update(actual, updater, options) {\n    return updater(actual, options)\n  },\n  equal(expected, actual) {\n    return R.equals(expected, actual)\n  },\n  async write(expected, { resolvedPath }) {\n    const unique = (array) =\u003e Array.from(new Set() \u003c T[number] \u003e array).sort()\n    await fs.writeFile(resolvedPath, unique(expected).join('\\n'), 'utf8')\n  },\n})\n\nexport default async (_workspaceDir) =\u003e {\n  return createUpdateOptions({\n    files: {\n      // builtin\n      'tsconfig.json': (actual, _options) =\u003e actual ?? tsconfig,\n      // buildin .json format with explicit format specifier\n      '.eslintrc [.json]': (actual) =\u003e actual ?? eslintrc,\n      // user-defined `#ignore` format\n      '.prettierignore [#ignore]': (actual) =\u003e actual ?? ['node_modules'],\n    },\n    formats: {\n      '#ignore': ignoreFormat,\n    },\n  })\n}\n```\n\nSee more examples at [src/examples/](src/examples/)\n\nTo perform the update on the affected config files, run `pnpm meta-updater`.\n\nTo check that all meta files are up-to-date, run `pnpm meta-updater --test`. It is recommended to always check the meta files before running the tests, so add it to your test command:\n\n```json\n{\n  \"test\": \"meta-updater --test \u0026\u0026 jest\"\n}\n```\n\n## API\n\n### Updater Function: `(config | null, dir, manifest) =\u003e Promise\u003cconfig | null\u003e`\n\nThe updater function recieves the config object or null (if the config file does not exist). The updater function returns the config object that should be saved. If the updater function returns null, the config should be removed.\n\n## License\n\n[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnpm%2Fmeta-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpnpm%2Fmeta-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnpm%2Fmeta-updater/lists"}