@coze-arch/rush-publish-plugin 0.0.1 → 0.0.3-alpha.f72758

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 (74) hide show
  1. package/{dist → lib}/action/publish/git.d.ts +2 -1
  2. package/lib/index.js +1631 -0
  3. package/package.json +26 -9
  4. package/dist/action/change/action.js +0 -40
  5. package/dist/action/change/amend-commit.js +0 -23
  6. package/dist/action/change/helper.js +0 -126
  7. package/dist/action/change/index.js +0 -17
  8. package/dist/action/change/types.js +0 -3
  9. package/dist/action/publish/action.js +0 -68
  10. package/dist/action/publish/apply-new-version.js +0 -27
  11. package/dist/action/publish/changelog.js +0 -79
  12. package/dist/action/publish/confirm.js +0 -31
  13. package/dist/action/publish/const.js +0 -5
  14. package/dist/action/publish/git.js +0 -33
  15. package/dist/action/publish/index.js +0 -43
  16. package/dist/action/publish/packages.js +0 -67
  17. package/dist/action/publish/push-to-remote.js +0 -105
  18. package/dist/action/publish/request-bump-type.js +0 -56
  19. package/dist/action/publish/types.js +0 -12
  20. package/dist/action/publish/version.js +0 -111
  21. package/dist/action/release/action.js +0 -34
  22. package/dist/action/release/git.js +0 -28
  23. package/dist/action/release/index.js +0 -31
  24. package/dist/action/release/manifest.js +0 -18
  25. package/dist/action/release/package.js +0 -49
  26. package/dist/action/release/plan.js +0 -37
  27. package/dist/action/release/release.js +0 -50
  28. package/dist/action/release/types.js +0 -3
  29. package/dist/generate-changelog/generate-changelog.js +0 -127
  30. package/dist/index.js +0 -28
  31. package/dist/types.js +0 -3
  32. package/dist/utils/exec.js +0 -24
  33. package/dist/utils/fs.d.ts +0 -4
  34. package/dist/utils/fs.js +0 -27
  35. package/dist/utils/get-rush-config.js +0 -16
  36. package/dist/utils/git.js +0 -70
  37. package/dist/utils/logger.d.ts +0 -58
  38. package/dist/utils/logger.js +0 -136
  39. package/dist/utils/random.js +0 -19
  40. package/dist/utils/whoami.js +0 -16
  41. package/src/index.ts +0 -32
  42. package/src/run.js +0 -7
  43. /package/{dist → lib}/action/change/action.d.ts +0 -0
  44. /package/{dist → lib}/action/change/amend-commit.d.ts +0 -0
  45. /package/{dist → lib}/action/change/helper.d.ts +0 -0
  46. /package/{dist → lib}/action/change/index.d.ts +0 -0
  47. /package/{dist → lib}/action/change/types.d.ts +0 -0
  48. /package/{dist → lib}/action/publish/action.d.ts +0 -0
  49. /package/{dist → lib}/action/publish/apply-new-version.d.ts +0 -0
  50. /package/{dist → lib}/action/publish/changelog.d.ts +0 -0
  51. /package/{dist → lib}/action/publish/confirm.d.ts +0 -0
  52. /package/{dist → lib}/action/publish/const.d.ts +0 -0
  53. /package/{dist → lib}/action/publish/index.d.ts +0 -0
  54. /package/{dist → lib}/action/publish/packages.d.ts +0 -0
  55. /package/{dist → lib}/action/publish/push-to-remote.d.ts +0 -0
  56. /package/{dist → lib}/action/publish/request-bump-type.d.ts +0 -0
  57. /package/{dist → lib}/action/publish/types.d.ts +0 -0
  58. /package/{dist → lib}/action/publish/version.d.ts +0 -0
  59. /package/{dist → lib}/action/release/action.d.ts +0 -0
  60. /package/{dist → lib}/action/release/git.d.ts +0 -0
  61. /package/{dist → lib}/action/release/index.d.ts +0 -0
  62. /package/{dist → lib}/action/release/manifest.d.ts +0 -0
  63. /package/{dist → lib}/action/release/package.d.ts +0 -0
  64. /package/{dist → lib}/action/release/plan.d.ts +0 -0
  65. /package/{dist → lib}/action/release/release.d.ts +0 -0
  66. /package/{dist → lib}/action/release/types.d.ts +0 -0
  67. /package/{dist → lib}/generate-changelog/generate-changelog.d.ts +0 -0
  68. /package/{dist → lib}/index.d.ts +0 -0
  69. /package/{dist → lib}/types.d.ts +0 -0
  70. /package/{dist → lib}/utils/exec.d.ts +0 -0
  71. /package/{dist → lib}/utils/get-rush-config.d.ts +0 -0
  72. /package/{dist → lib}/utils/git.d.ts +0 -0
  73. /package/{dist → lib}/utils/random.d.ts +0 -0
  74. /package/{dist → lib}/utils/whoami.d.ts +0 -0
package/dist/index.js DELETED
@@ -1,28 +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
- const path_1 = __importDefault(require("path"));
7
- const fs_1 = __importDefault(require("fs"));
8
- const commander_1 = require("commander");
9
- const release_1 = require("./action/release");
10
- const publish_1 = require("./action/publish");
11
- const change_1 = require("./action/change");
12
- const main = () => {
13
- const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(__dirname, '../package.json'), 'utf8'));
14
- const program = new commander_1.Command();
15
- program
16
- .name(packageJson.name)
17
- .description(packageJson.description)
18
- .version(packageJson.version)
19
- .showSuggestionAfterError(true)
20
- .showHelpAfterError(true);
21
- const actions = [change_1.installAction, release_1.installAction, publish_1.installAction];
22
- actions.forEach(a => {
23
- a(program);
24
- });
25
- program.parse();
26
- };
27
- main();
28
- //# sourceMappingURL=index.js.map
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -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,4 +0,0 @@
1
- export declare const readJsonFile: <T>(path: string) => Promise<T>;
2
- export declare const writeJsonFile: (path: string, data: unknown) => Promise<void>;
3
- export declare const isFileExists: (path: string) => Promise<boolean>;
4
- export declare const isDirExists: (path: string) => Promise<boolean>;
package/dist/utils/fs.js DELETED
@@ -1,27 +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.isDirExists = exports.isFileExists = exports.writeJsonFile = exports.readJsonFile = void 0;
7
- const promises_1 = __importDefault(require("fs/promises"));
8
- const readJsonFile = async (path) => {
9
- const content = await promises_1.default.readFile(path, 'utf8');
10
- return JSON.parse(content);
11
- };
12
- exports.readJsonFile = readJsonFile;
13
- const writeJsonFile = async (path, data) => {
14
- await promises_1.default.writeFile(path, JSON.stringify(data, null, 2), 'utf8');
15
- };
16
- exports.writeJsonFile = writeJsonFile;
17
- const isFileExists = async (path) => promises_1.default
18
- .access(path)
19
- .then(() => true)
20
- .catch(() => false);
21
- exports.isFileExists = isFileExists;
22
- const isDirExists = async (path) => promises_1.default
23
- .access(path)
24
- .then(() => true)
25
- .catch(() => false);
26
- exports.isDirExists = isDirExists;
27
- //# sourceMappingURL=fs.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/dist/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,58 +0,0 @@
1
- /**
2
- * 日志工具
3
- *
4
- * 提供统一的日志输出接口,支持不同级别的日志,包括彩色输出
5
- */
6
- export declare enum LogLevel {
7
- DEBUG = 0,
8
- INFO = 1,
9
- WARN = 2,
10
- ERROR = 3,
11
- SUCCESS = 4,
12
- NONE = 5
13
- }
14
- /**
15
- * 设置全局日志级别
16
- * @param level 日志级别
17
- */
18
- export declare function setLogLevel(level: LogLevel): void;
19
- /**
20
- * 获取当前日志级别
21
- * @returns 当前日志级别
22
- */
23
- export declare function getLogLevel(): LogLevel;
24
- /**
25
- * 导出的日志工具
26
- */
27
- export declare const logger: {
28
- /**
29
- * 调试日志
30
- * @param message 日志消息
31
- * @param showPrefix 是否显示前缀,默认为 true
32
- */
33
- debug(message: string, showPrefix?: boolean): void;
34
- /**
35
- * 信息日志
36
- * @param message 日志消息
37
- * @param showPrefix 是否显示前缀,默认为 true
38
- */
39
- info(message: string, showPrefix?: boolean): void;
40
- /**
41
- * 警告日志
42
- * @param message 日志消息
43
- * @param showPrefix 是否显示前缀,默认为 true
44
- */
45
- warn(message: string, showPrefix?: boolean): void;
46
- /**
47
- * 错误日志
48
- * @param message 日志消息
49
- * @param showPrefix 是否显示前缀,默认为 true
50
- */
51
- error(message: string, showPrefix?: boolean): void;
52
- /**
53
- * 成功日志
54
- * @param message 日志消息
55
- * @param showPrefix 是否显示前缀,默认为 true
56
- */
57
- success(message: string, showPrefix?: boolean): void;
58
- };
@@ -1,136 +0,0 @@
1
- "use strict";
2
- /**
3
- * 日志工具
4
- *
5
- * 提供统一的日志输出接口,支持不同级别的日志,包括彩色输出
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.logger = exports.LogLevel = void 0;
9
- exports.setLogLevel = setLogLevel;
10
- exports.getLogLevel = getLogLevel;
11
- // 日志级别枚举
12
- var LogLevel;
13
- (function (LogLevel) {
14
- LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
15
- LogLevel[LogLevel["INFO"] = 1] = "INFO";
16
- LogLevel[LogLevel["WARN"] = 2] = "WARN";
17
- LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
18
- LogLevel[LogLevel["SUCCESS"] = 4] = "SUCCESS";
19
- LogLevel[LogLevel["NONE"] = 5] = "NONE";
20
- })(LogLevel || (exports.LogLevel = LogLevel = {}));
21
- // ANSI 颜色代码
22
- const colors = {
23
- reset: '\x1b[0m',
24
- debug: '\x1b[36m', // 青色
25
- info: '\x1b[34m', // 蓝色
26
- warn: '\x1b[33m', // 黄色
27
- error: '\x1b[31m', // 红色
28
- success: '\x1b[32m', // 绿色
29
- };
30
- // 默认日志级别
31
- let currentLogLevel = LogLevel.INFO;
32
- /**
33
- * 设置全局日志级别
34
- * @param level 日志级别
35
- */
36
- function setLogLevel(level) {
37
- currentLogLevel = level;
38
- }
39
- /**
40
- * 获取当前日志级别
41
- * @returns 当前日志级别
42
- */
43
- function getLogLevel() {
44
- return currentLogLevel;
45
- }
46
- /**
47
- * 基础日志函数
48
- * @param level 日志级别
49
- * @param message 日志消息
50
- * @param showPrefix 是否显示前缀,默认为 true
51
- */
52
- function log(level, message, showPrefix = true) {
53
- if (level < currentLogLevel) {
54
- return;
55
- }
56
- let prefix = '';
57
- let color = '';
58
- switch (level) {
59
- case LogLevel.DEBUG: {
60
- prefix = '[DEBUG]';
61
- color = colors.debug;
62
- break;
63
- }
64
- case LogLevel.WARN: {
65
- prefix = '[WARN]';
66
- color = colors.warn;
67
- break;
68
- }
69
- case LogLevel.ERROR: {
70
- prefix = '[ERROR]';
71
- color = colors.error;
72
- break;
73
- }
74
- case LogLevel.SUCCESS: {
75
- prefix = '[SUCCESS]';
76
- color = colors.success;
77
- break;
78
- }
79
- case LogLevel.INFO:
80
- default: {
81
- prefix = '[INFO]';
82
- color = colors.info;
83
- break;
84
- }
85
- }
86
- // 格式化日志前缀
87
- const formattedPrefix = showPrefix ? `${color}${prefix}${colors.reset} ` : '';
88
- // 输出日志
89
- console.log(`${formattedPrefix}${message}`);
90
- }
91
- /**
92
- * 导出的日志工具
93
- */
94
- exports.logger = {
95
- /**
96
- * 调试日志
97
- * @param message 日志消息
98
- * @param showPrefix 是否显示前缀,默认为 true
99
- */
100
- debug(message, showPrefix = true) {
101
- log(LogLevel.DEBUG, message, showPrefix);
102
- },
103
- /**
104
- * 信息日志
105
- * @param message 日志消息
106
- * @param showPrefix 是否显示前缀,默认为 true
107
- */
108
- info(message, showPrefix = true) {
109
- log(LogLevel.INFO, message, showPrefix);
110
- },
111
- /**
112
- * 警告日志
113
- * @param message 日志消息
114
- * @param showPrefix 是否显示前缀,默认为 true
115
- */
116
- warn(message, showPrefix = true) {
117
- log(LogLevel.WARN, message, showPrefix);
118
- },
119
- /**
120
- * 错误日志
121
- * @param message 日志消息
122
- * @param showPrefix 是否显示前缀,默认为 true
123
- */
124
- error(message, showPrefix = true) {
125
- log(LogLevel.ERROR, message, showPrefix);
126
- },
127
- /**
128
- * 成功日志
129
- * @param message 日志消息
130
- * @param showPrefix 是否显示前缀,默认为 true
131
- */
132
- success(message, showPrefix = true) {
133
- log(LogLevel.SUCCESS, message, showPrefix);
134
- },
135
- };
136
- //# sourceMappingURL=logger.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
package/src/index.ts DELETED
@@ -1,32 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs';
3
-
4
- import { Command } from 'commander';
5
-
6
- import { installAction as releaseAction } from './action/release';
7
- import { installAction as publishAction } from './action/publish';
8
- import { installAction as generateChangeAction } from './action/change';
9
-
10
- const main = () => {
11
- const packageJson = JSON.parse(
12
- fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8'),
13
- );
14
- const program = new Command();
15
-
16
- program
17
- .name(packageJson.name)
18
- .description(packageJson.description)
19
- .version(packageJson.version)
20
- .showSuggestionAfterError(true)
21
- .showHelpAfterError(true);
22
-
23
- const actions = [generateChangeAction, releaseAction, publishAction];
24
-
25
- actions.forEach(a => {
26
- a(program);
27
- });
28
-
29
- program.parse();
30
- };
31
-
32
- main();
package/src/run.js DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- process.env.SUCRASE_OPTIONS = '{"preserveDynamicImport":true}';
4
- require('sucrase/register/ts');
5
- const path = require('path');
6
-
7
- require(path.resolve(__dirname, '../src/index.ts'));
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes