{"id":23003456,"url":"https://github.com/czfadmin/vsc-extension-helper","last_synced_at":"2026-04-28T11:04:02.103Z","repository":{"id":234253934,"uuid":"788521520","full_name":"czfadmin/vsc-extension-helper","owner":"czfadmin","description":"Use decorators or higher-order functions to help you register commands.","archived":false,"fork":false,"pushed_at":"2024-04-21T05:12:13.000Z","size":185,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-21T06:38:17.064Z","etag":null,"topics":["helper","vscode","vscode-extension"],"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/czfadmin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-18T15:21:31.000Z","updated_at":"2024-04-21T05:12:16.000Z","dependencies_parsed_at":"2024-04-20T06:36:04.218Z","dependency_job_id":"97845e0a-a46d-424a-aa3b-18a810ec203c","html_url":"https://github.com/czfadmin/vsc-extension-helper","commit_stats":null,"previous_names":["czfadmin/vsc-extension-helper"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czfadmin%2Fvsc-extension-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czfadmin%2Fvsc-extension-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czfadmin%2Fvsc-extension-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czfadmin%2Fvsc-extension-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czfadmin","download_url":"https://codeload.github.com/czfadmin/vsc-extension-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246829550,"owners_count":20840658,"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":["helper","vscode","vscode-extension"],"created_at":"2024-12-15T07:14:19.048Z","updated_at":"2026-04-28T11:03:57.064Z","avatar_url":"https://github.com/czfadmin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VSC Extension Helper\n\n![GitHub Release Date](https://img.shields.io/github/release-date/czfadmin/vsc-extension-helper?logo=github)\n![GitHub last commit](https://img.shields.io/github/last-commit/czfadmin/vsc-extension-helper?logo=github)\n\nUse decorators or higher-order functions to help you register commands.\n\n## Usage\n\n- Install the dependencies:\n\n```bash\n# yarn\nyarn add vsc-extension-helper\n\n# npm\nnpm install vsc-extension-helper\n\n```\n\n- If you use decorator syntax, modify `tsconfig.json` to enable the decorator experimental option, and modify the entry file to import `reflect-metadata`.\n\n```json\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    ...\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true,\n    ...\n  },\n}\n\n```\n\nAdd `import 'reflect-metadata'` at the beginning of the entry file\n\n```ts\n// extension.ts\nimport 'reflect-metadata';\n```\n\n- bootstrap your extension\n\n```ts\n// extension.ts\nimport 'reflect-metadata';\n\nimport {ExtensionContext} from 'vscode';\n\nimport {withActivate} from 'vsc-extension-helper/hoc';\n\n// your commands\nimport \"./commands\";\n\nexport const activate = withActivate({\n  extensionId: \u003cYour extension id\u003e,\n})(async function activate(context:ExtensionContext){\n  // Maybe this method is not good at the moment, but you need to dynamically import the command code file you wrote here, otherwise the command will fail to register.\n  // your code\n})\n\n```\n\n- register some commands\n\nUse decorator\n\n```ts\nimport { command, textEditorCommand } from 'vsc-extension-helper/decorators';\n\n// 1. use decorators\nclass CommandUtils {\n  @command({\n    name: 'command1',\n  })\n  command1() {\n    // do something\n  }\n\n  // register text editor command: command2\n  @textEditorCommand()\n  command2() {\n    // do something\n  }\n}\n```\n\nUse higher-order functions\n\n```ts\nimport { withCommand, withTextEditorCommand } from 'vsc-extension-helper/hoc';\n\n// register command3\nwithCommand({\n  name: 'command3',\n})(function command3(...args: any[]) {\n  // do something\n});\n\n// register command4\nwithTextEditorCommand(options)(function command4(...args: any[]) {});\n```\n\n## Example\n\n[Hello world](\"./examples/hello-world\")\n\nPS: Before running the sample code, please enter the home directory to **link** the package, and then test run the plug-in.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczfadmin%2Fvsc-extension-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczfadmin%2Fvsc-extension-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczfadmin%2Fvsc-extension-helper/lists"}