{"id":16493851,"url":"https://github.com/echosoar/mod-info","last_synced_at":"2025-06-11T02:05:35.550Z","repository":{"id":38844788,"uuid":"456144716","full_name":"echosoar/mod-info","owner":"echosoar","description":"Get the latest version update prompt of the node module (npm). 获取 node 模块最新版本更新提示","archived":false,"fork":false,"pushed_at":"2022-06-02T06:46:14.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-11T22:03:49.554Z","etag":null,"topics":["node-module","update-notifier"],"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/echosoar.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}},"created_at":"2022-02-06T12:29:19.000Z","updated_at":"2022-02-07T05:07:44.000Z","dependencies_parsed_at":"2022-09-08T02:42:40.391Z","dependency_job_id":null,"html_url":"https://github.com/echosoar/mod-info","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/echosoar%2Fmod-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fmod-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fmod-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fmod-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/echosoar","download_url":"https://codeload.github.com/echosoar/mod-info/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echosoar%2Fmod-info/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259184740,"owners_count":22818267,"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-module","update-notifier"],"created_at":"2024-10-11T14:10:55.668Z","updated_at":"2025-06-11T02:05:35.523Z","avatar_url":"https://github.com/echosoar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mod-info\nGet the latest version update prompt of the node module (npm).\n\n获取 node 模块最新版本更新提示\n\n[![npm](https://img.shields.io/npm/v/mod-info.svg?style=flat)](https://www.npmjs.org/package/mod-info)\n[![install size](https://packagephobia.com/badge?p=mod-info)](https://packagephobia.com/result?p=mod-info)\n![node-current (tag)](https://img.shields.io/node/v/mod-info/latest)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/echosoar/mod-info/master/LICENSE)\n\n\n\u003cbr /\u003e\n\n## 使用\n\n```bash\n$ npm i mod-info --save\n```\n\n```ts\n\nimport mi from 'mod-info';\n\n/*\n@params module name \u003cstring\u003e\n@params module current version \u003cstring\u003e\n@params? config \u003cIConfig\u003e 详见类型定义\n\n@return info \u003cIResult\u003e 详见类型定义\n*/\nconst info = await mi('test-mode-info', '1.1.4');\n/*\n{\n  update: true,     // 是否存在更新的版本\n  version: '1.2.4'  // 更新的版本号\n  tips: [           // 一些更新内容提示\n    '一些更新内容提示'\n  ]\n}\n*/\n```\n## 类型定义\n### IConfig\n```ts\ntype ILevelConfig = 'major' | 'minor' | 'patch';\ninterface IConfig {\n  // 配置更新提示等级\n  // 配置为 major 时只有发布更高 major 版本了才认为更新\n  // 配置为 minor 时只有发布了相同 major 版本，且 minor 版本更高才认为更新\n  // 配置为 patch 时只有发布了相同 major 和 minor 版本，且 patch 版本更高才认为更新\n  // 默认值为 ['major', 'minor', 'patch']\n  level?: ILevelConfig[];\n\n  // 检测更新间隔，单位为 毫秒，默认为 24 * 60 * 60 * 1000，即一天内只检测一次\n  timeout?: number;\n\n  // 是否忽略非正式版本的更新，例如 1.2-beta.3 这种 beta 版本，默认为 true\n  ignoreInformalVersion?: boolean;\n}\n```\n### IResult\n```ts\ninterface IResult {\n  // 是否存在（当前检测规则 level 下的）最新版本\n  update: boolean;\n\n  // 如果存在最新版本，它的版本号是\n  version: string;\n  \n  // 当前版本匹配到的 更新提示信息 列表\n  tips: string[];\n}\n```\n\n## 更新提示信息配置\n\n在模块的 `package.json` 中通过 `module-info-tips` 可以配置 `更新提示信息`，使用 `mod-info` 检测版本时会获取到这些提示信息。\n\n更新提示信息可以通过 `match` 和 `ignore` 两个字段来匹配或忽略在某些版本下提示，同时支持使用 `*` 或 `x` 来匹配任意版本，例如：\n\n```json\n{\n  \"name\": \"test-mode-info\",\n  \"version\": \"1.2.4\",\n  \"module-info-tips\": [\n    {\n      \"match\": \"0\",\n      \"ignore\": \"0.1.*\",\n      \"tip\": \"0.x tip\"\n    },\n    {\n      \"match\": [\"1.2\", \"1.3\"],\n      \"ignore\": [\"1.2.3\"],\n      \"tip\": \"1.x tip\"\n    },\n    {\n      \"match\": \"*\",\n      \"ignore\": \"*.1\",\n      \"tip\": \"x tip\"\n    }\n  ]\n}\n\n```\n\n---\n\nMIT LICENSE\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechosoar%2Fmod-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fechosoar%2Fmod-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechosoar%2Fmod-info/lists"}