# Js 数据格式
打算开发一个 go 语言的依赖关系解析器。
第一步解决 npm 的依赖关系。
在 npm_records 里面有 package.json 的数据,一个文档对应于一个组件的 package.json。其数据类似于:
{ | |
'_id': ObjectId("610540ac4744ffaaa609b725"), | |
'name': "field-descriptions", | |
'version': "1.0.7", | |
'__v': 0, | |
'detail': { | |
'name': "field-descriptions", | |
'version': "1.0.7", | |
'description': "Make key-value data easier to display in discord embeds", | |
'main': "lib/index.js", | |
'types': "lib", | |
'scripts': { | |
'build': "tsc -p .", | |
'example': "ts-node-dev examples/webhook.ts" | |
}, | |
'keywords': [ | |
], | |
'repository': { | |
'type': "git", | |
'url': "git+https://github.com/arifali123/field-descriptions.git" | |
}, | |
'homepage': "https://github.com/arifali123/field-descriptions", | |
'bugs': { | |
'url': "https://github.com/arifali123/field-descriptions/issues" | |
}, | |
'author': { | |
'name': "arifali123" | |
}, | |
'license': "MIT", | |
'devDependencies': { | |
'@types/lodash': "^4.14.165", | |
'discord-webhook-node': "^1.1.8", | |
'ts-node-dev': "^1.1.1", | |
'typescript': "^4.1.2" | |
}, | |
'dependencies': { | |
'lodash': "^4.17.20" | |
}, | |
'gitHead': "7f8f63d58ef91ba9192d8a30da5fd609e03c6f91", | |
'_id': "field-descriptions@1.0.7", | |
'_nodeVersion': "14.15.1", | |
'_npmVersion': "6.14.9", | |
} | |
} | |
} |
我们主要关注的就是 devDependencies
和 dependencies
这两个字段,这是这个组件的直接依赖。
而 npm_metas
这个集合里记录了每个组件的 metadata
{ | |
'_id': ObjectId("61053ef8f8a0eaaea4cdb756"), | |
'releases': [ | |
{ | |
'version': "1.0.0", | |
'time': ISODate("2017-07-26T09:48:03.776Z") | |
}, | |
{ | |
'version': "1.0.1", | |
'time': ISODate("2017-07-26T09:58:44.154Z") | |
}, | |
{ | |
'version': "1.0.2", | |
'time': ISODate("2017-07-27T10:13:23.808Z") | |
} | |
], | |
'name': "005", | |
'status': "Normal", | |
'lastUpdatedAt': ISODate("2021-08-06T13:17:06.906Z"), | |
'nextUpdateAt': ISODate("2022-05-25T09:58:44.154Z"), | |
'__v': 0, | |
'created': ISODate("2017-07-26T09:48:03.776Z"), | |
'modified': ISODate("2017-07-27T10:13:23.808Z") | |
} |
可以看到,在 releases
字段里面记录了这个组件的每次更新时间,我们的目的就是只关注 2022 年的信息。
# Composer 数据格式
records 数据格式
{ | |
'_id': ObjectId("61857f314744ffaaa6ce062f"), | |
'name': "yii2-cmslib/redis", | |
'version': "2.6.4", | |
'__v': 0, | |
'detail': { | |
'name': "yii2-cmslib/redis", | |
'description': "Redis class, For yii2 extention. Support multiple configuration.", | |
'keywords': [ | |
"redis", | |
"extension", | |
"multiple", | |
"yii2" | |
], | |
'homepage': "", | |
'version': "2.6.4", | |
'version_normalized': "2.6.4.0", | |
'license': [ | |
"BSD-3-Clause" | |
], | |
'authors': [ | |
{ | |
'name': "https://github.com/cunwang", | |
'email': "lodrw@sina.com" | |
} | |
], | |
'source': { | |
'type': "git", | |
'url': "https://github.com/cunwang/yii2-cmslib.git", | |
'reference': "2bfbad74b6ad4727c7c03d34920f950340f103cc" | |
}, | |
'dist': { | |
'type': "zip", | |
'url': "https://api.github.com/repos/cunwang/yii2-cmslib/zipball/2bfbad74b6ad4727c7c03d34920f950340f103cc", | |
'reference': "2bfbad74b6ad4727c7c03d34920f950340f103cc", | |
'shasum': "" | |
}, | |
'type': "yii2-extension", | |
'support': { | |
'issues': "https://github.com/cunwang/yii2-cmslib/issues?q=labels=ext%3Aimagine", | |
'forum': "http://www.yiiframework.com/forum/", | |
'wiki': "http://www.yiiframework.com/wiki/", | |
'irc': "irc://irc.freenode.net/yii", | |
'source': "https://github.com/cunwang/yii2-cmslib" | |
}, | |
'time': "2016-01-05T00:33:57+00:00", | |
'autoload': { | |
'psr-4': { | |
'Yii2cms\lib\': "" | |
} | |
}, | |
'require': { | |
'yiisoft/yii2': "*" | |
} | |
} | |
}, |
Metas 格式
{ | |
'_id': ObjectId("61855c353a9156708d7b7bec"), | |
'releases': [ | |
{ | |
'version': "dev-master", | |
'time': "2021-05-23T09:40:43+00:00" | |
}, | |
{ | |
'version': "dev-patch-2", | |
'time': "2021-05-16T05:10:33+00:00" | |
}, | |
{ | |
'version': "dev-patch-1", | |
'time': "2021-05-16T03:19:10+00:00" | |
}, | |
{ | |
'version': "1.0.0", | |
'time': "2021-05-23T09:40:43+00:00" | |
}, | |
{ | |
'version': "v0.1.0-beta.16.2", | |
'time': "2021-04-24T06:50:38+00:00" | |
}, | |
{ | |
'version': "v0.1.0-beta.16.1", | |
'time': "2021-03-22T04:15:52+00:00" | |
}, | |
{ | |
'version': "v0.1.0-beta.16", | |
'time': "2021-03-16T11:53:21+00:00" | |
}, | |
{ | |
'version': "v0.1.0-beta.15.2", | |
'time': "2021-03-01T13:04:30+00:00" | |
}, | |
{ | |
'version': "v0.1.0-beta.15.1", | |
'time': "2021-01-24T15:20:26+00:00" | |
}, | |
{ | |
'version': "v0.1.0-beta.15", | |
'time': "2020-12-23T06:15:30+00:00" | |
} | |
], | |
'name': "0.1.x-dev/lang-simplified-chinese", | |
'status': "Normal", | |
'lastUpdatedAt': ISODate("2021-12-29T07:03:49.352Z"), | |
'nextUpdateAt': ISODate("2022-08-24T06:15:30.000Z"), | |
'__v': 0 | |
}, |