{"id":25303587,"url":"https://github.com/apptools-lab/codemod","last_synced_at":"2025-04-07T02:32:18.824Z","repository":{"id":44168904,"uuid":"377425484","full_name":"apptools-lab/codemod","owner":"apptools-lab","description":"🐒 AppWorks codemod scripts","archived":false,"fork":false,"pushed_at":"2021-09-08T04:05:26.000Z","size":35,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T07:37:32.608Z","etag":null,"topics":["codemod","codemods"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apptools-lab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-16T08:30:02.000Z","updated_at":"2023-04-22T02:50:05.000Z","dependencies_parsed_at":"2022-08-27T22:01:47.028Z","dependency_job_id":null,"html_url":"https://github.com/apptools-lab/codemod","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apptools-lab%2Fcodemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apptools-lab%2Fcodemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apptools-lab%2Fcodemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apptools-lab%2Fcodemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apptools-lab","download_url":"https://codeload.github.com/apptools-lab/codemod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247581670,"owners_count":20961811,"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":["codemod","codemods"],"created_at":"2025-02-13T07:37:06.563Z","updated_at":"2025-04-07T02:32:18.746Z","avatar_url":"https://github.com/apptools-lab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @appworks/codemod\n\nAppWorks codemod scripts for [rax](https://rax.js.org/), [ice](https://ice.work/) and react project.\n\n## Install\n\n```bash\n$ npm i @appworks/codemod -g\n```\n\n## Usage\n\n### 1. CLI\n\n```bash\n$ appworks-codemod \u003ctransform\u003e \u003cpath\u003e [...options?]\n```\n\n- `transform` - name of transform, see available transforms below.\n- `path` - files or directory to transform.\n- `options?` - option for [jscodeshift](https://www.npmjs.com/package/jscodeshift).\n\nExample:\n\n```bash\n$ appworks-codemod plugin-rax-component-to-component ./\n```\n\n### 2. API\n\n#### Check()\n\nYou can retrieve the recommended codemod of the current project through the `check` method.\n\nOptions:\n\n- directory: string, the target directory path\n- files: string[], the target directory files path array\n\nReturn:\n\n- results: IResult[] (see interface), the target project recommended codemod info array.\n\nExample:\n\n```javascript\nimport glob from \"glob\";\nimport { check } from \"@appworks/codemod\";\n\nconst dir = \"/xxx/xx\";\n\nglob(\n  \"**/*\",\n  { cwd: dir, ignore: [\"**/node_modules/**\"], nodir: true, realpath: true },\n  function (er, files) {\n    check(dir, files).then((results) =\u003e {\n      console.log(results);\n    });\n  }\n);\n```\n\n#### Run()\n\nYou can use the `run` method to execute specific codemod.\n\nOptions:\n\n- directory: string, the target directory path\n- files: string[], the target directory files path array\n- transform: string, the name of transform, see available transforms below.\n\nReturn:\n\n- result: IResult (see interface), run codemod result.\n\nExample:\n\n```javascript\nimport glob from \"glob\";\nimport { check } from \"@appworks/codemod\";\n\nconst dir = \"/xxx/xx\";\n\nglob(\n  \"**/*\",\n  { cwd: dir, ignore: [\"**/node_modules/**\"], nodir: true, realpath: true },\n  function (er, files) {\n    run(dir, files, \"plugin-rax-component-to-component\").then((result) =\u003e {\n      console.log(result);\n    });\n  }\n);\n```\n\n#### Interface\n\nIResult:\n\n```typescript\ninterface IResult {\n  transform: string; // transform key, see `Included Transforms`\n  title: string; // transform description title\n  title_en: string; \n  message: string; // transform description message\n  message_en: string; \n  severity: 0 | 1 | 2; // 0: advice 1: warning 2: error\n  mode: \"run\" | \"check\"; // mode, see API\n  docs: string; // docs url\n  output: string; // jscodeshift CLI output\n  npm_deprecate?: string; // same as https://docs.npmjs.com/cli/v7/commands/npm-deprecate/ \n}\n```\n\n## Included Transforms\n\n### 1. `plugin-rax-component-to-component`\n\nUpdate `plugin-rax-component` to `plugin-component`. [docs](./transforms/docs/plugin-rax-component-to-component.md)\n\n### 2. `lint-config-to-spec`\n\nFollow Alibaba FED lint rules, and use `@iceworks/spec` best practices. [docs](./transforms/docs/lint-config-to-spec.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapptools-lab%2Fcodemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapptools-lab%2Fcodemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapptools-lab%2Fcodemod/lists"}