karin-plugin-kkk 1.0.4-commit.16cac2b → 1.0.4-commit.db43730
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/pr.js +4 -3
- package/package.json +1 -1
package/lib/cli/pr.js
CHANGED
|
@@ -14,15 +14,16 @@ const readPkg = () => JSON.parse(fs.readFileSync(getPkgPath(), 'utf-8'));
|
|
|
14
14
|
*/
|
|
15
15
|
const writePkg = (pkg) => fs.writeFileSync(getPkgPath(), JSON.stringify(pkg, null, 2));
|
|
16
16
|
/**
|
|
17
|
-
* @description 构建pr版本号 <主版本号>.<次版本号>.<修订号>.<PR
|
|
17
|
+
* @description 构建pr版本号 <主版本号>.<次版本号>.<修订号>.<PR标识PR编号>.<当前提交唯一短哈希>
|
|
18
18
|
* @example 1.0.0.pr.184.a1b2c3d
|
|
19
19
|
* @param pkg package.json
|
|
20
20
|
*/
|
|
21
21
|
const updateVersion = (pkg) => {
|
|
22
22
|
const list = pkg.version.split('.');
|
|
23
|
-
|
|
23
|
+
console.log('PR_COMMIT_HASH' + process.env.PR_COMMIT_HASH);
|
|
24
|
+
const shortHash = process.env.PR_COMMIT_HASH?.substring(0, 7) ?? 'unknown';
|
|
24
25
|
list[2] = `${Number(list[2]) + 1}`;
|
|
25
|
-
pkg.version = `${list.join('.')}
|
|
26
|
+
pkg.version = `${list.join('.')}-pr${process.env.PR_NUMBER}.${shortHash}`;
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* @description 设置环境变量
|