自从我们升级到 Artifactory 版本 6.12.1 以来,发布 Node.js 包时出现了新的行为。我们的package.json主要是这样的(为了保密修改了一些信息):
{
"name": "@org/module-test",
"version": "1.0.0-12345",
"description": "Module's description",
"scripts": {
<scripts>
},
"repository": {
"type": "git",
"url": "<git repo url>"
},
"license": "UNLICENSED",
"devDependencies": {
"husky": "^1.3.1"
},
"publishConfig": {
"registry": "https://<artifactory_url>/api/npm/npm-local/",
"_auth": "<API token>"
},
"files": [
"<app-folder>"
],
"husky": {
"hooks": {
<several hooks>
}
}
}
这里重要的部分是版本参数。如果我执行 npmpublish,在该配置中,一切正常,并且 json 和 tgz 文件具有相同的名称。但是,当版本看起来像这样时:
"version": "1.0.0-123abc"
tgz 文件的名称是这样的,但是 npm info 选项卡中的 Version 以及相应的 json 文件是这样写的:
module-test-1.0.0-123-abc.json
每次版本包含该格式的数字和字母时,都会添加破折号 (-),这会影响我们自动化使用这些包的管道的能力。这是有问题的,因为我们输入 git commit 哈希值作为版本号,所以每当哈希值以数字开头并跟随字母时,就会出现问题。
我们之前的 6.1.0 版本没有出现此问题。与 npm 存储库相关的先前配置和实际配置之间没有重大差异。对于有问题的版本号,这是 event.log
文件中显示的内容:
1569867062896|create|npm-local/@org/module-test/-/@org/module-test-1.0.0-123abc.tgz
1569867062896|props|npm-local/@org/module-test/-/@org/module-test-1.0.0-123abc.tgz
1569867062896|create|npm-local/.npm/@org/module-test/@org/module-test-1.0.0-123-abc.json
1569867062896|props|npm-local/@org/module-test/-/@org/module-test-1.0.0-123abc.tgz
1569867063055|props|npm-local/@org/module-test/-/@org/module-test-1.0.0-12abc.tgz
我们可以看到,仅修改了 json 文件的名称。
如果我们在主版本和子版本之间插入一个字符串,问题就会消失,如下所示:
"version":"1.0.0-string-123abc"
这应该是一个临时的解决方法,比较困难,因为按照我们的标准,它并不能产生“干净”的版本 ID。
不确定这是否相关,但这是 npm-local 存储库使用的 npm-default 存储库布局:
<repoLayout>
<name>npm-default</name>
<artifactPathPattern>[orgPath]/[module]/[module]-[baseRev](-[fileItegRev]).tgz</artifactPathPattern>
<distinctiveDescriptorPathPattern>false</distinctiveDescriptorPathPattern>
<folderIntegrationRevisionRegExp>.*</folderIntegrationRevisionRegExp>
<fileIntegrationRevisionRegExp>.*</fileIntegrationRevisionRegExp>
</repoLayout>
可以找到repoLayout的文档here
我们希望 json 文件、tgz 存档和版本 ID 保持不变,无论版本号是什么。为什么要添加这个破折号,我们不知道,但我们需要它消失。这是我们不知道的新配置,还是一个错误?
最佳答案
这是最近版本中引入的问题。我们计划在即将发布的版本之一中修复它。您可以关注https://www.jfrog.com/jira/browse/RTFACT-20247更多细节。
关于node.js - 推送到本地 Artifactory 存储库时修改了 NPM 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58174310/