{"id":20758543,"url":"https://github.com/obweger/modster","last_synced_at":"2025-04-30T03:47:36.933Z","repository":{"id":88257028,"uuid":"260440441","full_name":"obweger/modster","owner":"obweger","description":"A plugin system and CLI for consuming and executing jscodeshift codemods, in a way that is not terrible.","archived":false,"fork":false,"pushed_at":"2023-12-15T17:48:28.000Z","size":198,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T03:47:29.243Z","etag":null,"topics":["cli","codemod","codemods","jscodeshift","plugin"],"latest_commit_sha":null,"homepage":"","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/obweger.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":"2020-05-01T11:12:55.000Z","updated_at":"2022-05-17T16:29:48.000Z","dependencies_parsed_at":"2023-12-15T18:44:29.677Z","dependency_job_id":"9f5730d4-0462-4220-b918-dcfaf952c28e","html_url":"https://github.com/obweger/modster","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obweger%2Fmodster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obweger%2Fmodster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obweger%2Fmodster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obweger%2Fmodster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obweger","download_url":"https://codeload.github.com/obweger/modster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251638756,"owners_count":21619662,"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":["cli","codemod","codemods","jscodeshift","plugin"],"created_at":"2024-11-17T09:51:56.122Z","updated_at":"2025-04-30T03:47:36.882Z","avatar_url":"https://github.com/obweger.png","language":"TypeScript","readme":"# Modster\n\n\u003e Codemoding, the easy way.\n\nModster is a plugin system and CLI for consuming and executing [`jscodeshift`](https://github.com/facebook/jscodeshift) codemods, in a way that is not terrible.\n\nIn Modster, you pick your codemod from a list of codemods, answer a few questions to have it configured, choose a file or directory to run against - and off you go! \n\nEasy? Yes, much. ✌️\n\n![Modster in action](./assets/full-run-top-half.png)\n\n\u003cdetails\u003e\n\u003csummary\u003eSee the full run.\u003c/summary\u003e\n\n![Modster in full action](./assets/full-run-bottom-half.png)\n\n\u003c/details\u003e\n\n## Installation\n\nE.g. using `yarn`:\n\n```shell\n$ yarn install modster\n$ yarn modster\n```\n\n## Configuration\n\n### `.codemods.js`\n\nModster is configured via a configuration file, typically named `.codemods.js`. It is expected to export an object with the following fields:\n\n| Field | Type | Required | Description |\n|- |-|-|-|\n| `packageManager` | `string` | ✅ | Your package manager; typically `yarn` or `npm`. |\n| `sourceDirectory` | `string`   | ✅ | The directory on which you want codemods to operate. You can further limit the scope of a codemod when running Modster. |\n| `extensions` | `string[]` | ✅ | The file extensions you want to run codemods against. Passed to `jscodeshift` as the `--ext` option. |\n| `parser` | `string` | ✅ | The parser to use for parsing source files. One of `babel \\| babylon \\| flow \\| ts \\| tsx`. Passed to `jscodeshift` as the `--parser` option. |\n| `plugins` | `string[]` | ✅ | A list of Modster plugins, following the [`eslint`-style plugin naming convention](https://github.com/obweger/plugin-name-to-package-name). See below for a list of existing plugins and how to create your own plugins. |\n| `postUpdateTasks` | `function` | | A function of the shape `(updatedFiles: string[]) =\u003e { name: string; cmd: string }[]`, receiving the list of files modified by a codemod, and return a list of tasks to be executed. Every task has a `name` (e.g. `prettier`) and a `command` to be executed (e.g. `yarn run prettier ...`). |\n\n\u003cdetails\u003e\n  \u003csummary\u003eLike so.\u003c/summary\u003e\n  \n  ```js\n    export default {\n        packageManager: 'yarn',\n        extensions: ['tsx', 'ts'],\n        sourceFolder: 'src',\n        parser: 'tsx',\n        plugins: [\n            'hello-world'\n        ],\n        postUpdateTask: (files: string[]) =\u003e [\n            {\n                name: 'eslint autofix',\n                command: `yarn eslint ${files.join(' ')} --ext tsx,ts --fix`\n            }\n        ]\n    }\n  ```\n\n\u003c/details\u003e\n\n### CLI options\n\nModster takes two optional CLI options, `--config \u003cpath-to-file\u003e`, and `--dry`.\n\n| Option | Description |\n|-|-|\n| `--config \u003cpath-to-file\u003e` | The path to Modster's configuration file, relative to `process.cwd()`. Defaults to `./codemods`. |\n| `--dry` | If set, runs `jscodeshift` in a dry run. Post-update tasks are printed but not executed. |\n\n## Plugins\n\nModster uses a plugin system to consume codemods, similar to how e.g. `eslint` consumes linting rules. It is important to understand that Modser comes with no built-in codemod functionality; running Modster without plugins therefore doesn't make a huge amount of sense. But good news! - using and even writing Modster plugins is dead simple: \n\n### Existing plugins\n\nTo consume a Modster plugin, you simply install it as an `npm` package, e.g. using `yarn`:\n\n```shell\n$ yarn install modster-plugin-hello-world\n```\n\n... and add it to your `.codemods.js`, following the [`eslint`-style plugin naming convention](https://github.com/obweger/plugin-name-to-package-name):\n\n```diff\nmodule.exports = {\n    // ...\n    plugins: [\n        // ...\n+      'hello-world'\n    ]\n}\n```\n\nSee below for a list of Modster plugins:\n\n| Plugin | Description |\n|-|-|\n| [Hello World](https://github.com/obweger/modster-plugin-hello-world) | A minimal plugin example; mostly a reference for [developing new plugins](./docs/developing-plugins/README.md). |\n\n_To add a plugin to this list, please raise a PR._\n\n### Developing plugins\n\nSee [Developing Modster plugins](./docs/developing-plugins/README.md).\n\n## Contributions\n\nYes please!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobweger%2Fmodster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobweger%2Fmodster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobweger%2Fmodster/lists"}