{"id":25923867,"url":"https://github.com/keminghe/npm-template","last_synced_at":"2026-05-05T10:33:53.899Z","repository":{"id":279731191,"uuid":"939757207","full_name":"KemingHe/npm-template","owner":"KemingHe","description":"Template for creating TypeScript utility packages for publishing to NPM registry.","archived":false,"fork":false,"pushed_at":"2025-02-28T16:02:27.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T20:26:52.387Z","etag":null,"topics":["node","npm","pnpm","template","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@keminghe/npm-template","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/KemingHe.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":"2025-02-27T03:59:09.000Z","updated_at":"2025-02-28T16:00:01.000Z","dependencies_parsed_at":"2025-02-27T05:21:38.428Z","dependency_job_id":"d13e351c-e140-4818-b1f1-7ad5d3afcefe","html_url":"https://github.com/KemingHe/npm-template","commit_stats":null,"previous_names":["keminghe/node-utils-template","keminghe/npm-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KemingHe%2Fnpm-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KemingHe%2Fnpm-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KemingHe%2Fnpm-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KemingHe%2Fnpm-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KemingHe","download_url":"https://codeload.github.com/KemingHe/npm-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241705919,"owners_count":20006399,"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":["node","npm","pnpm","template","typescript"],"created_at":"2025-03-03T17:18:26.253Z","updated_at":"2026-05-05T10:33:53.893Z","avatar_url":"https://github.com/KemingHe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚠️ [Archived] ⚠️ @keminghe/npm-template\n\n\u003e [!WARNING]\n\u003e **This repository is archived and no longer maintained.**\n\u003e\n\u003e - **Archived**: 2025-08-10 by [@KemingHe](https://github.com/KemingHe)\n\u003e - **Archive reason**: moved on to more focused agentic AI development\n\u003e - **Inquries and corrections**: email [keminghe.career@gmail.com](mailto:keminghe.career@gmail.com)\n\n![npm-template social preview - TypeScript utility package template by KemingHe](https://socialify.git.ci/KemingHe/npm-template/image?description=1\u0026language=1\u0026name=1\u0026owner=1\u0026theme=Light)\n\n![NPM Version](https://img.shields.io/npm/v/%40keminghe%2Fnpm-template)\n![NPM License](https://img.shields.io/npm/l/%40keminghe%2Fnpm-template)\n[![codecov](https://codecov.io/gh/KemingHe/npm-template/graph/badge.svg?token=ryf67P7bm9)](https://codecov.io/gh/KemingHe/npm-template)\n\nTemplate for creating TypeScript utility packages for publishing to NPM registry. Social preview generated with [Socialify](https://socialify.git.ci).\n\n## ⭐ Features\n\n- 📝 Full TypeScript support with comprehensive type definitions\n- ⚡️ Zero runtime dependencies with 100% test coverage\n- 🔄 Automated releases with Git hooks and strict linting\n\n## 📥 Installation\n\n```bash\nnpm install @keminghe/npm-template\n```\n\n## 🚀 Usage\n\n### Environment Variable Utility\n\n```typescript\nimport { env } from '@keminghe/npm-template';\n\n// Basic usage\n// Throws runtime error if API_KEY is missing or empty\nconst apiKey: string = env('API_KEY');\n\n// With default value and pattern validation\nconst port: string = env('PORT', {\n  defaultValue: '3000',\n  pattern: /^[0-9]+$/\n});\n```\n\n### String Validation\n\n```typescript\nimport { isNonEmptyString } from '@keminghe/npm-template';\n\nconst value = 'hello';\nif (isNonEmptyString(value)) {\n  // TypeScript knows value is string here\n  console.log(value.toUpperCase());\n}\n```\n\n### _Your Custom Utility_\n\n```typescript\n// Add your utility functions here\n// Follow similar pattern for type safety and validation\nimport { YourUtility } from './your-module';\n\n// Document clear usage examples\nconst result = YourUtility.process('input');\n```\n\n## 📚 API\n\n### `env(name: string, options?: EnvOptions): string`\n\nRetrieves and validates an environment variable value.\n\n**Parameters:**\n\n- `name` - Environment variable name\n- `options` - Optional configuration object\n  - `defaultValue?: string` - Fallback if env var is not set\n  - `pattern?: RegExp` - Validation pattern to test against\n\n**Returns:**\n\n- `string` - The validated environment variable value\n\n**Throws:**\n\n- `Error` if the variable is missing/empty with no default\n- `Error` if the value doesn't match the specified pattern\n\n```typescript\n// Examples\nconst apiKey = env('API_KEY');  // Throws if not set\n\nconst port = env('PORT', {\n  defaultValue: '3000',\n  pattern: /^\\d+$/\n});\n```\n\n### `isNonEmptyString(value: unknown): value is string`\n\nType guard that checks if a value is a non-empty string.\n\n**Parameters:**\n\n- `value` - Any value to test\n\n**Returns:**\n\n- `boolean` - `true` if value is a non-empty string\n\n```typescript\nconst input = someValue;\nif (isNonEmptyString(input)) {\n  // TypeScript knows input is string here\n  console.log(input.length);\n}\n```\n\n### _Your Custom API_\n\n_Document your new functions following this format:_\n\n```typescript\n/**\n * Brief description of what the function does\n * @param paramName - Parameter description\n * @returns What the function returns\n * @throws Error conditions if applicable\n */\nfunction yourFunction(paramName: ParamType): ReturnType {\n  // Implementation\n}\n```\n\n## ⚙️ Development\n\n```bash\npnpm install  # Install dependencies\n\npnpm test     # Run tests\n\npnpm build    # Build package\n\npnpm verify   # Full verification\n```\n\n## 🏷️ Release Process\n\nSee [Tag and Publish Guide](https://github.com/KemingHe/npm-template/blob/main/docs/tag-and-publish.md) for detailed instructions on:\n\n- Setting up GPG signing\n- Creating signed Git tags\n- Automatic NPM publishing via GitHub Actions\n\n## 🤝 Contributing\n\n1. Fork the repository to your GitHub account\n2. Create a feature branch (`git checkout -b feature/my-update`)\n3. Make changes and commit (`git commit`) with Commitizen\n4. Push your changes (`git push origin feature/my-update`)\n5. Create a Pull Request for code review\n\n## 📄 License\n\n[MIT License](https://github.com/KemingHe/npm-template/blob/main/LICENSE)\n\nCopyright 2025 [Keming He](http://linkedin.com/in/keminghe)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeminghe%2Fnpm-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeminghe%2Fnpm-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeminghe%2Fnpm-template/lists"}