@coze-arch/rush-publish-plugin 0.0.1 → 0.0.3

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 (73) hide show
  1. package/{dist → lib}/action/change/action.js +1 -1
  2. package/{dist → lib}/action/change/helper.js +1 -1
  3. package/{dist → lib}/action/publish/action.js +1 -1
  4. package/{dist → lib}/action/publish/apply-new-version.js +4 -4
  5. package/{dist → lib}/action/publish/changelog.js +6 -6
  6. package/{dist → lib}/action/publish/git.d.ts +2 -1
  7. package/{dist → lib}/action/publish/git.js +7 -4
  8. package/{dist → lib}/action/publish/index.js +1 -1
  9. package/{dist → lib}/action/publish/push-to-remote.js +4 -2
  10. package/{dist → lib}/action/release/action.js +1 -1
  11. package/{dist → lib}/action/release/index.js +3 -3
  12. package/{dist → lib}/action/release/package.js +3 -3
  13. package/{dist → lib}/action/release/plan.js +2 -1
  14. package/{dist → lib}/action/release/release.js +3 -3
  15. package/package.json +16 -7
  16. package/dist/utils/fs.d.ts +0 -4
  17. package/dist/utils/fs.js +0 -27
  18. package/dist/utils/logger.d.ts +0 -58
  19. package/dist/utils/logger.js +0 -136
  20. package/src/index.ts +0 -32
  21. package/src/run.js +0 -7
  22. /package/{dist → lib}/action/change/action.d.ts +0 -0
  23. /package/{dist → lib}/action/change/amend-commit.d.ts +0 -0
  24. /package/{dist → lib}/action/change/amend-commit.js +0 -0
  25. /package/{dist → lib}/action/change/helper.d.ts +0 -0
  26. /package/{dist → lib}/action/change/index.d.ts +0 -0
  27. /package/{dist → lib}/action/change/index.js +0 -0
  28. /package/{dist → lib}/action/change/types.d.ts +0 -0
  29. /package/{dist → lib}/action/change/types.js +0 -0
  30. /package/{dist → lib}/action/publish/action.d.ts +0 -0
  31. /package/{dist → lib}/action/publish/apply-new-version.d.ts +0 -0
  32. /package/{dist → lib}/action/publish/changelog.d.ts +0 -0
  33. /package/{dist → lib}/action/publish/confirm.d.ts +0 -0
  34. /package/{dist → lib}/action/publish/confirm.js +0 -0
  35. /package/{dist → lib}/action/publish/const.d.ts +0 -0
  36. /package/{dist → lib}/action/publish/const.js +0 -0
  37. /package/{dist → lib}/action/publish/index.d.ts +0 -0
  38. /package/{dist → lib}/action/publish/packages.d.ts +0 -0
  39. /package/{dist → lib}/action/publish/packages.js +0 -0
  40. /package/{dist → lib}/action/publish/push-to-remote.d.ts +0 -0
  41. /package/{dist → lib}/action/publish/request-bump-type.d.ts +0 -0
  42. /package/{dist → lib}/action/publish/request-bump-type.js +0 -0
  43. /package/{dist → lib}/action/publish/types.d.ts +0 -0
  44. /package/{dist → lib}/action/publish/types.js +0 -0
  45. /package/{dist → lib}/action/publish/version.d.ts +0 -0
  46. /package/{dist → lib}/action/publish/version.js +0 -0
  47. /package/{dist → lib}/action/release/action.d.ts +0 -0
  48. /package/{dist → lib}/action/release/git.d.ts +0 -0
  49. /package/{dist → lib}/action/release/git.js +0 -0
  50. /package/{dist → lib}/action/release/index.d.ts +0 -0
  51. /package/{dist → lib}/action/release/manifest.d.ts +0 -0
  52. /package/{dist → lib}/action/release/manifest.js +0 -0
  53. /package/{dist → lib}/action/release/package.d.ts +0 -0
  54. /package/{dist → lib}/action/release/plan.d.ts +0 -0
  55. /package/{dist → lib}/action/release/release.d.ts +0 -0
  56. /package/{dist → lib}/action/release/types.d.ts +0 -0
  57. /package/{dist → lib}/action/release/types.js +0 -0
  58. /package/{dist → lib}/generate-changelog/generate-changelog.d.ts +0 -0
  59. /package/{dist → lib}/generate-changelog/generate-changelog.js +0 -0
  60. /package/{dist → lib}/index.d.ts +0 -0
  61. /package/{dist → lib}/index.js +0 -0
  62. /package/{dist → lib}/types.d.ts +0 -0
  63. /package/{dist → lib}/types.js +0 -0
  64. /package/{dist → lib}/utils/exec.d.ts +0 -0
  65. /package/{dist → lib}/utils/exec.js +0 -0
  66. /package/{dist → lib}/utils/get-rush-config.d.ts +0 -0
  67. /package/{dist → lib}/utils/get-rush-config.js +0 -0
  68. /package/{dist → lib}/utils/git.d.ts +0 -0
  69. /package/{dist → lib}/utils/git.js +0 -0
  70. /package/{dist → lib}/utils/random.d.ts +0 -0
  71. /package/{dist → lib}/utils/random.js +0 -0
  72. /package/{dist → lib}/utils/whoami.d.ts +0 -0
  73. /package/{dist → lib}/utils/whoami.js +0 -0
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateChangeFiles = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const promises_1 = __importDefault(require("fs/promises"));
9
- const logger_1 = require("../../utils/logger");
9
+ const logger_1 = require("@coze-arch/logger");
10
10
  const get_rush_config_1 = require("../../utils/get-rush-config");
11
11
  const helper_1 = require("./helper");
12
12
  const amend_commit_1 = require("./amend-commit");
@@ -10,8 +10,8 @@ exports.analysisCommitMsg = analysisCommitMsg;
10
10
  exports.generateAllChangesFile = generateAllChangesFile;
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const ChangeFile_1 = require("@rushstack/rush-sdk/lib/api/ChangeFile");
13
+ const logger_1 = require("@coze-arch/logger");
13
14
  const whoami_1 = require("../../utils/whoami");
14
- const logger_1 = require("../../utils/logger");
15
15
  const git_1 = require("../../utils/git");
16
16
  const get_rush_config_1 = require("../../utils/get-rush-config");
17
17
  const exec_1 = require("../../utils/exec");
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.publish = void 0;
4
+ const logger_1 = require("@coze-arch/logger");
4
5
  const random_1 = require("../../utils/random");
5
- const logger_1 = require("../../utils/logger");
6
6
  const git_1 = require("../../utils/git");
7
7
  const get_rush_config_1 = require("../../utils/get-rush-config");
8
8
  const version_1 = require("./version");
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyPublishManifest = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const logger_1 = require("../../utils/logger");
9
- const fs_1 = require("../../utils/fs");
8
+ const logger_1 = require("@coze-arch/logger");
9
+ const fs_enhance_1 = require("@coze-arch/fs-enhance");
10
10
  const updatePackageVersion = async (project, newVersion) => {
11
11
  const packageJsonPath = path_1.default.resolve(project.projectFolder, 'package.json');
12
- const packageJson = await (0, fs_1.readJsonFile)(packageJsonPath);
12
+ const packageJson = await (0, fs_enhance_1.readJsonFile)(packageJsonPath);
13
13
  packageJson.version = newVersion;
14
- await (0, fs_1.writeJsonFile)(packageJsonPath, packageJson);
14
+ await (0, fs_enhance_1.writeJsonFile)(packageJsonPath, packageJson);
15
15
  return packageJsonPath;
16
16
  };
17
17
  const applyPublishManifest = async (manifests) => {
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateChangelog = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const promises_1 = __importDefault(require("fs/promises"));
9
+ const fs_enhance_1 = require("@coze-arch/fs-enhance");
9
10
  const get_rush_config_1 = require("../../utils/get-rush-config");
10
- const fs_1 = require("../../utils/fs");
11
11
  const generate_changelog_1 = require("../../generate-changelog/generate-changelog");
12
12
  const deleteFiles = async (files) => {
13
13
  await Promise.all(files.map(async (file) => {
@@ -15,7 +15,7 @@ const deleteFiles = async (files) => {
15
15
  }));
16
16
  };
17
17
  const readChangeFiles = async (changedFolderOfPkg) => {
18
- if (!(await (0, fs_1.isDirExists)(changedFolderOfPkg))) {
18
+ if (!(await (0, fs_enhance_1.isDirExists)(changedFolderOfPkg))) {
19
19
  return [];
20
20
  }
21
21
  const changeFiles = (await promises_1.default.readdir(changedFolderOfPkg)).filter(r => r.endsWith('.json'));
@@ -24,7 +24,7 @@ const readChangeFiles = async (changedFolderOfPkg) => {
24
24
  const readChanges = async (changeFiles) => {
25
25
  const changes = (await Promise.all(changeFiles.map(async (r) => {
26
26
  try {
27
- const res = await (0, fs_1.readJsonFile)(r);
27
+ const res = await (0, fs_enhance_1.readJsonFile)(r);
28
28
  return res;
29
29
  }
30
30
  catch (e) {
@@ -38,11 +38,11 @@ const readPreviousChangelog = async (changelogJsonPath, packageName) => {
38
38
  name: packageName,
39
39
  entries: [],
40
40
  };
41
- if (!(await (0, fs_1.isFileExists)(changelogJsonPath))) {
41
+ if (!(await (0, fs_enhance_1.isFileExists)(changelogJsonPath))) {
42
42
  return defaultValue;
43
43
  }
44
44
  try {
45
- const changelog = await (0, fs_1.readJsonFile)(changelogJsonPath);
45
+ const changelog = await (0, fs_enhance_1.readJsonFile)(changelogJsonPath);
46
46
  return changelog;
47
47
  }
48
48
  catch (e) {
@@ -66,7 +66,7 @@ const generateChangelogForProject = async (manifest) => {
66
66
  previousChangelog,
67
67
  });
68
68
  // side effects
69
- await (0, fs_1.writeJsonFile)(changelogJsonPath, changelog);
69
+ await (0, fs_enhance_1.writeJsonFile)(changelogJsonPath, changelog);
70
70
  await promises_1.default.writeFile(changelogMarkdownPath, changelogMarkdown);
71
71
  await deleteFiles(changeFiles);
72
72
  return [changelogJsonPath, changelogMarkdownPath, ...changeFiles];
@@ -6,8 +6,9 @@ interface CommitChangesOptions {
6
6
  cwd: string;
7
7
  publishManifests: PublishManifest[];
8
8
  branchName: string;
9
+ createTags: boolean;
9
10
  }
10
- export declare function commitChanges({ sessionId, files, cwd, publishManifests, branchName, }: CommitChangesOptions): Promise<{
11
+ export declare function commitChanges({ sessionId, files, cwd, publishManifests, branchName, createTags, }: CommitChangesOptions): Promise<{
11
12
  effects: string[];
12
13
  branchName: string;
13
14
  }>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAndPushBranch = createAndPushBranch;
4
4
  exports.commitChanges = commitChanges;
5
5
  exports.push = push;
6
- const logger_1 = require("../../utils/logger");
6
+ const logger_1 = require("@coze-arch/logger");
7
7
  const exec_1 = require("../../utils/exec");
8
8
  async function createAndPushBranch(branchName, cwd) {
9
9
  try {
@@ -18,11 +18,14 @@ async function createAndPushBranch(branchName, cwd) {
18
18
  throw new Error(`Failed to create/push branch: ${error}`);
19
19
  }
20
20
  }
21
- async function commitChanges({ sessionId, files, cwd, publishManifests, branchName, }) {
21
+ async function commitChanges({ sessionId, files, cwd, publishManifests, branchName, createTags, }) {
22
22
  await (0, exec_1.exec)(`git add ${files.join(' ')}`, { cwd });
23
23
  await (0, exec_1.exec)(`git commit -m "chore: Publish ${branchName}" -n`, { cwd });
24
- const tags = publishManifests.map(m => `v/${m.project.packageName}@${m.newVersion}`);
25
- await (0, exec_1.exec)(tags.map(tag => `git tag -a ${tag} -m "Bump type ${tag}"`).join(' && '), { cwd });
24
+ let tags = [];
25
+ if (createTags) {
26
+ tags = publishManifests.map(m => `v/${m.project.packageName}@${m.newVersion}`);
27
+ await (0, exec_1.exec)(tags.map(tag => `git tag -a ${tag} -m "Bump type ${tag}"`).join(' && '), { cwd });
28
+ }
26
29
  return { effects: [...tags, branchName], branchName };
27
30
  }
28
31
  async function push({ refs, cwd, repoUrl }) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.installAction = void 0;
4
- const logger_1 = require("../../utils/logger");
4
+ const logger_1 = require("@coze-arch/logger");
5
5
  const git_1 = require("../../utils/git");
6
6
  const const_1 = require("./const");
7
7
  const action_1 = require("./action");
@@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.pushToRemote = void 0;
40
40
  const dayjs_1 = __importDefault(require("dayjs"));
41
- const logger_1 = require("../../utils/logger");
41
+ const logger_1 = require("@coze-arch/logger");
42
42
  const git_1 = require("../../utils/git");
43
43
  const exec_1 = require("../../utils/exec");
44
44
  const types_1 = require("./types");
@@ -60,6 +60,7 @@ const pushToRemote = async (options) => {
60
60
  branchName = `release/${date}-${sessionId}`;
61
61
  await (0, exec_1.exec)(`git checkout -b ${branchName}`, { cwd });
62
62
  }
63
+ const isTestPublish = [types_1.BumpType.ALPHA, types_1.BumpType.BETA].includes(bumpPolicy);
63
64
  // 4. 创建并推送发布分支
64
65
  const { effects } = await (0, git_2.commitChanges)({
65
66
  sessionId,
@@ -67,6 +68,8 @@ const pushToRemote = async (options) => {
67
68
  cwd,
68
69
  publishManifests,
69
70
  branchName,
71
+ // 只有 alpha、beta 需要创建 tag,正式发布会在 .github/workflows/common-pr-checks.yml 创建并发布tag
72
+ createTags: isTestPublish,
70
73
  });
71
74
  if (skipPush) {
72
75
  return;
@@ -76,7 +79,6 @@ const pushToRemote = async (options) => {
76
79
  cwd,
77
80
  repoUrl: actualRepoUrl,
78
81
  });
79
- const isTestPublish = [types_1.BumpType.ALPHA, types_1.BumpType.BETA].includes(bumpPolicy);
80
82
  // 从 git URL 提取组织和仓库名称,用于构建 GitHub 链接
81
83
  const repoInfoMatch = actualRepoUrl.match(const_1.GIT_REPO_URL_REGEX);
82
84
  if (!repoInfoMatch) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.release = release;
4
- const logger_1 = require("../../utils/logger");
4
+ const logger_1 = require("@coze-arch/logger");
5
5
  const git_1 = require("../../utils/git");
6
6
  const exec_1 = require("../../utils/exec");
7
7
  const release_1 = require("./release");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.installAction = void 0;
4
- const logger_1 = require("../../utils/logger");
4
+ const logger_1 = require("@coze-arch/logger");
5
5
  const action_1 = require("./action");
6
6
  const installAction = (program) => {
7
7
  program
@@ -15,8 +15,8 @@ const installAction = (program) => {
15
15
  if (!options.commit) {
16
16
  throw new Error('请提供需要发布的 commit id');
17
17
  }
18
- if (!process.env.NODE_AUTH_TOKEN) {
19
- throw new Error('请设置 NODE_AUTH_TOKEN 环境变量');
18
+ if (!process.env.NPM_AUTH_TOKEN) {
19
+ throw new Error('请设置 NPM_AUTH_TOKEN 环境变量');
20
20
  }
21
21
  await (0, action_1.release)(options);
22
22
  }
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.applyPublishConfig = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
+ const fs_enhance_1 = require("@coze-arch/fs-enhance");
8
9
  const get_rush_config_1 = require("../../utils/get-rush-config");
9
- const fs_1 = require("../../utils/fs");
10
10
  /**
11
11
  * 更新依赖版本
12
12
  */
@@ -39,11 +39,11 @@ const applyPublishConfig = async (project) => {
39
39
  applyCozePublishConfig,
40
40
  ];
41
41
  const packageJsonPath = path_1.default.join(project.projectFolder, 'package.json');
42
- let packageJson = await (0, fs_1.readJsonFile)(packageJsonPath);
42
+ let packageJson = await (0, fs_enhance_1.readJsonFile)(packageJsonPath);
43
43
  for (const job of jobs) {
44
44
  packageJson = await job(packageJson);
45
45
  }
46
- await (0, fs_1.writeJsonFile)(packageJsonPath, packageJson);
46
+ await (0, fs_enhance_1.writeJsonFile)(packageJsonPath, packageJson);
47
47
  };
48
48
  exports.applyPublishConfig = applyPublishConfig;
49
49
  //# sourceMappingURL=package.js.map
@@ -28,7 +28,8 @@ const calReleasePlan = (releaseManifests) => {
28
28
  };
29
29
  const checkReleasePlan = (releaseManifests, branchName) => {
30
30
  const releasePlan = calReleasePlan(releaseManifests);
31
- if (releasePlan === ReleaseType.LATEST && branchName !== 'main') {
31
+ if (releasePlan === ReleaseType.LATEST &&
32
+ !['main', 'feat/auto-publish'].includes(branchName)) {
32
33
  throw new Error('For LATEST release, should be on main branch only.');
33
34
  }
34
35
  return true;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.releasePackages = void 0;
4
- const logger_1 = require("../../utils/logger");
4
+ const logger_1 = require("@coze-arch/logger");
5
5
  const exec_1 = require("../../utils/exec");
6
6
  const package_1 = require("./package");
7
7
  /**
@@ -9,14 +9,14 @@ const package_1 = require("./package");
9
9
  */
10
10
  const publishPackage = async (project, releaseOptions) => {
11
11
  const { dryRun, registry } = releaseOptions;
12
- const token = process.env.NODE_AUTH_TOKEN;
12
+ const token = process.env.NPM_AUTH_TOKEN;
13
13
  const { version } = project.packageJson;
14
14
  const tag = version.includes('alpha')
15
15
  ? 'alpha'
16
16
  : version.includes('beta')
17
17
  ? 'beta'
18
18
  : 'latest';
19
- const args = [`NODE_AUTH_TOKEN=${token}`, 'npm', 'publish', `--tag ${tag}`];
19
+ const args = [`NPM_AUTH_TOKEN=${token}`, 'npm', 'publish', `--tag ${tag}`];
20
20
  if (dryRun) {
21
21
  args.push('--dry-run');
22
22
  }
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "@coze-arch/rush-publish-plugin",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "rush plugin to generate change log and publish packages",
5
+ "keywords": [
6
+ "rush",
7
+ "plugin",
8
+ "command",
9
+ "release",
10
+ "publish"
11
+ ],
5
12
  "license": "ISC",
6
13
  "author": "tecvan.fe@gmail.com",
7
14
  "maintainers": [],
8
- "main": "src/index.ts",
15
+ "main": "./lib/index.js",
9
16
  "bin": {
10
- "rush-publish": "./src/run.js"
17
+ "rush-publish": "./lib/index.js"
11
18
  },
12
19
  "files": [
13
- "dist",
20
+ "lib",
14
21
  "!**/*.tsbuildinfo",
15
22
  "!**/*.map",
16
23
  "command-line.json",
@@ -23,6 +30,8 @@
23
30
  "test:cov": "npm run test -- --coverage"
24
31
  },
25
32
  "dependencies": {
33
+ "@coze-arch/fs-enhance": "0.0.1",
34
+ "@coze-arch/logger": "0.0.1",
26
35
  "@inquirer/prompts": "^3.2.0",
27
36
  "@rushstack/rush-sdk": "^5.150.0",
28
37
  "chalk": "^4.1.2",
@@ -55,8 +64,8 @@
55
64
  },
56
65
  "cozePublishConfig": {
57
66
  "bin": {
58
- "rush-publish": "./dist/run.js"
67
+ "rush-publish": "./lib/index.js"
59
68
  },
60
- "main": "./dist/index.js"
69
+ "main": "./lib/index.js"
61
70
  }
62
- }
71
+ }
@@ -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,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
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
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