{"id":19904370,"url":"https://github.com/alloc/codegentool","last_synced_at":"2025-05-03T00:31:37.119Z","repository":{"id":231154063,"uuid":"781063980","full_name":"alloc/codegentool","owner":"alloc","description":"Run code-generating scripts with one command and as files change","archived":true,"fork":false,"pushed_at":"2024-06-03T05:56:13.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T21:02:29.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alloc.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":"2024-04-02T17:21:36.000Z","updated_at":"2024-11-11T17:00:45.000Z","dependencies_parsed_at":"2024-04-02T18:51:21.955Z","dependency_job_id":"5d56ffed-b0bb-4a48-8b43-8e2b3ccf9653","html_url":"https://github.com/alloc/codegentool","commit_stats":null,"previous_names":["alloc/codegentool"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fcodegentool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fcodegentool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fcodegentool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fcodegentool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alloc","download_url":"https://codeload.github.com/alloc/codegentool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252126559,"owners_count":21698964,"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-12T20:28:06.928Z","updated_at":"2025-05-03T00:31:36.459Z","avatar_url":"https://github.com/alloc.png","language":"JavaScript","funding_links":["https://paypal.me/alecdotbiz"],"categories":[],"sub_categories":[],"readme":"# codegentool\n\n[![npm](https://img.shields.io/npm/v/codegentool.svg)](https://www.npmjs.com/package/codegentool)\n[![Code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/alecdotbiz)\n\n\u003e Run code-generating scripts with one command and as files change\n\n\u0026nbsp;\n\n### Configuration\n\nIf customization is desired, you may add a `codegentool` field to your `package.json`. By default,\nany JS/TS modules in the `./generators` directory will be run.\n\n```json\n{\n  \"codegentool\": {\n    \"generators\": [\"./generators/*.ts\"]\n  }\n}\n```\n\nGenerators can be uncompiled TypeScript, no problem. Every generator needs to export a default function which will be called with Codegentool's runtime API.\n\n```ts\nimport { defineGenerator } from 'codegentool'\n\nexport default defineGenerator(({ scan }) =\u003e {\n  const files = await scan('src/**/*.ts')\n  // ...\n})\n```\n\n\u0026nbsp;\n\n### Usage\n\n```ts\npnpm install -D codegentool@npm:@alloc/codegentool\n```\n\nRun your project's configured generators:\n\n```sh\npnpm codegentool\n```\n\nRerun them as files change:\n\n```sh\npnpm codegentool -w\n```\n\n\u0026nbsp;\n\n## Runtime API\n\nThe runtime API is passed to each generator function. As of now, it's only for filesystem operations, so that Codegentool can watch for changes.\n\n### scan()\n\nAlias to [`fast-glob`](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#api) package with\nfile-watching support.\n\nNote: In watch mode, changes to files matching the glob will trigger a rerun even though they\nshouldn't.\n\n### read()\n\nAlias to `fs.readFileSync` with file-watching support.\n\n### write()\n\nAlias to `fs.writeFileSync` but it won't write if nothing changed.\n\n### writeEnv()\n\nCreate or update a `.env` file with the given data. Pass `null` to unset a key.\n\n### dedent()\n\nAlias to [`dedent`](https://github.com/dmnd/dedent?tab=readme-ov-file#usage) package.\n\n### serialize()\n\nAlias to [`serialize-javascript`](https://github.com/yahoo/serialize-javascript) package.\n\n### parseModule()\n\nGiven a module path, parse the module and return the AST. Both JSX and TypeScript are supported with no extra configuration.\n\nWe use [`meriyah`](https://github.com/meriyah/meriyah) for parsing.\n\n### parseModuleText()\n\nGiven a string of code, parse it and return the AST. Both JSX and TypeScript are supported with no extra configuration.\n\n### loadModule()\n\nSimilar to `import()` but returns null instead of rejecting when a module is not found. Also has an optional `basedir` argument for resolution. Finally, the default `basedir` is the directory of the bundled generator (which defaults to somewhere in `node_modules/.cache/codegentool`). Relative imports are resolved as if the import was executed from the generator's source path.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Fcodegentool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falloc%2Fcodegentool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Fcodegentool/lists"}