@coze-arch/rush-publish-plugin 0.0.3 → 0.0.5-alpha.0f1107

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.
Files changed (38) hide show
  1. package/command-line.json +11 -3
  2. package/lib/action/publish/packages.d.ts +1 -1
  3. package/lib/action/publish/version.d.ts +1 -1
  4. package/lib/index.js +1882 -25
  5. package/lib/utils/ci.d.ts +86 -0
  6. package/package.json +13 -9
  7. package/lib/action/change/action.js +0 -40
  8. package/lib/action/change/amend-commit.js +0 -23
  9. package/lib/action/change/helper.js +0 -126
  10. package/lib/action/change/index.js +0 -17
  11. package/lib/action/change/types.js +0 -3
  12. package/lib/action/publish/action.js +0 -68
  13. package/lib/action/publish/apply-new-version.js +0 -27
  14. package/lib/action/publish/changelog.js +0 -79
  15. package/lib/action/publish/confirm.js +0 -31
  16. package/lib/action/publish/const.js +0 -5
  17. package/lib/action/publish/git.js +0 -36
  18. package/lib/action/publish/index.js +0 -43
  19. package/lib/action/publish/packages.js +0 -67
  20. package/lib/action/publish/push-to-remote.js +0 -107
  21. package/lib/action/publish/request-bump-type.js +0 -56
  22. package/lib/action/publish/types.js +0 -12
  23. package/lib/action/publish/version.js +0 -111
  24. package/lib/action/release/action.js +0 -34
  25. package/lib/action/release/git.js +0 -28
  26. package/lib/action/release/index.js +0 -31
  27. package/lib/action/release/manifest.js +0 -18
  28. package/lib/action/release/package.js +0 -49
  29. package/lib/action/release/plan.js +0 -38
  30. package/lib/action/release/release.js +0 -50
  31. package/lib/action/release/types.js +0 -3
  32. package/lib/generate-changelog/generate-changelog.js +0 -127
  33. package/lib/types.js +0 -3
  34. package/lib/utils/exec.js +0 -24
  35. package/lib/utils/get-rush-config.js +0 -16
  36. package/lib/utils/git.js +0 -70
  37. package/lib/utils/random.js +0 -19
  38. package/lib/utils/whoami.js +0 -16
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateChangelog = void 0;
7
- const semver_1 = __importDefault(require("semver"));
8
- const dayjs_1 = __importDefault(require("dayjs"));
9
- /**
10
- * Convert change type to corresponding title
11
- */
12
- const getChangeTypeTitle = (type) => {
13
- switch (type) {
14
- case 'major':
15
- return '### Breaking Changes';
16
- case 'minor':
17
- return '### New Features';
18
- case 'patch':
19
- return '### Bug Fixes';
20
- case 'dependency':
21
- return '### Dependencies';
22
- case 'none':
23
- return '### Other Changes';
24
- default:
25
- return '';
26
- }
27
- };
28
- /**
29
- * Generate changelog for a single version
30
- */
31
- const generateVersionChangelog = ({ version, changes, tag, defaultChangelog, }) => {
32
- // Group changes by type
33
- const groupedChanges = changes.length > 0
34
- ? changes.reduce((acc, change) => {
35
- const { type, comment, customFields } = change;
36
- if (!acc[type]) {
37
- acc[type] = [];
38
- }
39
- const node = acc[type];
40
- if (node.some(existing => existing.comment === comment) === false) {
41
- node.push({
42
- comment,
43
- customFields,
44
- });
45
- }
46
- return acc;
47
- }, {})
48
- : { none: [{ comment: defaultChangelog }] };
49
- return {
50
- version,
51
- tag,
52
- date: (0, dayjs_1.default)().toISOString(),
53
- comments: groupedChanges,
54
- };
55
- };
56
- /**
57
- * Convert changelog to Markdown format
58
- */
59
- const changelogToMarkdown = (changelog) => {
60
- const lines = [];
61
- lines.push(`# ${changelog.name}`);
62
- lines.push('');
63
- changelog.entries.forEach(entry => {
64
- lines.push(`## ${entry.version} - ${(0, dayjs_1.default)(entry.date).format('YYYY-MM-DD')}`);
65
- lines.push('');
66
- // Output different types of changes in fixed order
67
- const typeOrder = [
68
- 'major',
69
- 'minor',
70
- 'patch',
71
- 'dependency',
72
- 'none',
73
- ];
74
- typeOrder.forEach(type => {
75
- const changes = entry.comments[type];
76
- if (changes?.length) {
77
- lines.push(getChangeTypeTitle(type));
78
- lines.push('');
79
- changes.forEach(change => {
80
- lines.push(`- ${change.comment}`);
81
- // Add custom fields to changelog if they exist
82
- if (change.customFields) {
83
- Object.entries(change.customFields).forEach(([key, value]) => {
84
- lines.push(` - ${key}: ${value}`);
85
- });
86
- }
87
- });
88
- lines.push('');
89
- }
90
- });
91
- lines.push('');
92
- });
93
- return lines.join('\n');
94
- };
95
- /**
96
- * Merge and generate changelog
97
- */
98
- const generateChangelog = ({ commingChanges, previousChangelog, version, packageName, tag, defaultChangelog = 'Publish for noop', }) => {
99
- // Create new changelog entry
100
- const newEntry = generateVersionChangelog({
101
- version,
102
- changes: commingChanges.flatMap(r => r.changes),
103
- tag: tag || 'HEAD',
104
- defaultChangelog,
105
- });
106
- const allEntries = (previousChangelog ? [newEntry, ...previousChangelog.entries] : [newEntry]).sort((a, b) => {
107
- // Handle invalid version numbers
108
- if (!semver_1.default.valid(a.version) || !semver_1.default.valid(b.version)) {
109
- return 0;
110
- }
111
- // Use semver.rcompare for descending sort (newer versions first)
112
- return semver_1.default.rcompare(a.version, b.version);
113
- });
114
- // Merge with existing changelog
115
- const changelog = {
116
- name: packageName,
117
- entries: allEntries,
118
- };
119
- // Convert to markdown
120
- const markdown = changelogToMarkdown(changelog);
121
- return {
122
- changelog,
123
- report: markdown,
124
- };
125
- };
126
- exports.generateChangelog = generateChangelog;
127
- //# sourceMappingURL=generate-changelog.js.map
package/lib/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/lib/utils/exec.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exec = void 0;
4
- const shelljs_1 = require("shelljs");
5
- class ExecError extends Error {
6
- constructor(result) {
7
- super(result.stderr || result.stdout);
8
- this.code = result.code;
9
- this.stderr = result.stderr;
10
- this.stdout = result.stdout;
11
- }
12
- }
13
- const exec = (cmd, options = { silent: true }) => new Promise((r, j) => {
14
- (0, shelljs_1.exec)(cmd, options, (code, stdout, stderr) => {
15
- if (code === 0) {
16
- r({ code, stdout, stderr });
17
- }
18
- else {
19
- j(new ExecError({ code, stderr, stdout }));
20
- }
21
- });
22
- });
23
- exports.exec = exec;
24
- //# sourceMappingURL=exec.js.map
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRushConfiguration = void 0;
4
- const rush_sdk_1 = require("@rushstack/rush-sdk");
5
- exports.getRushConfiguration = (() => {
6
- let rushConfiguration = null;
7
- return (useCache = true) => {
8
- if (!useCache) {
9
- rushConfiguration = null;
10
- }
11
- return (rushConfiguration || (rushConfiguration = rush_sdk_1.RushConfiguration.loadFromDefaultLocation({
12
- startingFolder: process.cwd(),
13
- })));
14
- };
15
- })();
16
- //# sourceMappingURL=get-rush-config.js.map
package/lib/utils/git.js DELETED
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertGitSchemaToHttp = exports.getCurrentOrigin = exports.ensureNotUncommittedChanges = exports.getChangedFiles = exports.isMainBranch = exports.getCurrentBranchName = exports.getChangedFilesFromCached = void 0;
4
- const exec_1 = require("./exec");
5
- const serializeFilesName = (output) => output
6
- .split('\n')
7
- .map(line => {
8
- if (line) {
9
- const trimmedLine = line.trim();
10
- return trimmedLine;
11
- }
12
- return '';
13
- })
14
- .filter(line => line && line.length > 0);
15
- const getChangedFilesFromCached = async () => {
16
- const output = await (0, exec_1.exec)('git diff --name-only --diff-filter=ACMR --cached');
17
- if (!output) {
18
- return [];
19
- }
20
- return serializeFilesName(output.stdout);
21
- };
22
- exports.getChangedFilesFromCached = getChangedFilesFromCached;
23
- /**
24
- * 获取当前分支名称
25
- * @returns string
26
- */
27
- const getCurrentBranchName = async () => {
28
- const { stdout } = await (0, exec_1.exec)('git rev-parse --abbrev-ref HEAD');
29
- return stdout.trim();
30
- };
31
- exports.getCurrentBranchName = getCurrentBranchName;
32
- const isMainBranch = async () => {
33
- const currentBranchName = await (0, exports.getCurrentBranchName)();
34
- return currentBranchName === 'main';
35
- };
36
- exports.isMainBranch = isMainBranch;
37
- const getChangedFiles = async () => {
38
- const output = await (0, exec_1.exec)('git diff --name-only --diff-filter=ACMR');
39
- return serializeFilesName(output.stdout);
40
- };
41
- exports.getChangedFiles = getChangedFiles;
42
- /**
43
- * 确保没有未提交的变更
44
- */
45
- const ensureNotUncommittedChanges = async () => {
46
- const changedFiles = (await Promise.all([(0, exports.getChangedFilesFromCached)(), (0, exports.getChangedFiles)()])).flat();
47
- if (changedFiles.length > 0) {
48
- throw new Error('There are uncommitted changes in the working tree, please commit them first.');
49
- }
50
- return true;
51
- };
52
- exports.ensureNotUncommittedChanges = ensureNotUncommittedChanges;
53
- /**
54
- * 获取当前 Git 仓库设置的 origin 远程源地址
55
- * @param cwd 当前工作目录
56
- * @returns origin 远程源地址
57
- */
58
- const getCurrentOrigin = async (cwd = process.cwd()) => {
59
- try {
60
- const { stdout } = await (0, exec_1.exec)('git remote get-url origin', { cwd });
61
- return stdout.trim();
62
- }
63
- catch (error) {
64
- return undefined;
65
- }
66
- };
67
- exports.getCurrentOrigin = getCurrentOrigin;
68
- const convertGitSchemaToHttp = (gitUrl) => gitUrl.replace('git@', 'https://').replace(':', '/').replace('.git', '');
69
- exports.convertGitSchemaToHttp = convertGitSchemaToHttp;
70
- //# sourceMappingURL=git.js.map
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.randomHash = randomHash;
7
- const crypto_1 = __importDefault(require("crypto"));
8
- /**
9
- * 生成指定长度的随机字符串(使用 crypto 模块)
10
- * @param digit 字符串长度
11
- * @returns 随机字符串
12
- */
13
- function randomHash(digit) {
14
- return crypto_1.default
15
- .randomBytes(Math.ceil(digit / 2))
16
- .toString('hex')
17
- .slice(0, digit);
18
- }
19
- //# sourceMappingURL=random.js.map
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.whoAmI = void 0;
4
- const exec_1 = require("./exec");
5
- const whoAmI = async () => {
6
- const [name, email] = await Promise.all([
7
- (0, exec_1.exec)('git config user.name', { cwd: __dirname, silent: true }),
8
- (0, exec_1.exec)('git config user.email', { cwd: __dirname, silent: true }),
9
- ]);
10
- return {
11
- name: name.stdout.toString().replace('\n', ''),
12
- email: email.stdout.toString().replace('\n', ''),
13
- };
14
- };
15
- exports.whoAmI = whoAmI;
16
- //# sourceMappingURL=whoami.js.map