zcw-shared 1.14.0 → 1.15.0

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 (34) hide show
  1. package/dist/functions/git/checkBranch.d.ts +30 -0
  2. package/dist/functions/git/checkBranch.js +71 -0
  3. package/dist/functions/git/checkBranch.js.map +1 -0
  4. package/dist/functions/git/checkWorkingDirectory.d.ts +3 -0
  5. package/dist/functions/git/checkWorkingDirectory.js +41 -0
  6. package/dist/functions/git/checkWorkingDirectory.js.map +1 -0
  7. package/dist/functions/git/createGitTag.d.ts +7 -0
  8. package/dist/functions/git/createGitTag.js +36 -0
  9. package/dist/functions/git/createGitTag.js.map +1 -0
  10. package/dist/functions/git/pushToRemote.d.ts +34 -0
  11. package/dist/functions/git/pushToRemote.js +51 -0
  12. package/dist/functions/git/pushToRemote.js.map +1 -0
  13. package/dist/functions/ipc/dispatchIpcRequest.d.ts +11 -1
  14. package/dist/functions/ipc/dispatchIpcRequest.js +20 -7
  15. package/dist/functions/ipc/dispatchIpcRequest.js.map +1 -1
  16. package/dist/functions/package/readPackageInfo.d.ts +3 -0
  17. package/dist/functions/package/readPackageInfo.js +53 -0
  18. package/dist/functions/package/readPackageInfo.js.map +1 -0
  19. package/dist/functions/tencent-cloud/deploy.tcb.d.ts +3 -0
  20. package/dist/functions/tencent-cloud/deploy.tcb.js +47 -0
  21. package/dist/functions/tencent-cloud/deploy.tcb.js.map +1 -0
  22. package/dist/functions/tencent-cloud/getSecret.d.ts +4 -6
  23. package/dist/functions/tencent-cloud/getSecret.js +1 -0
  24. package/dist/functions/tencent-cloud/getSecret.js.map +1 -1
  25. package/dist/functions/version/incrementVersion.d.ts +3 -0
  26. package/dist/functions/version/incrementVersion.js +57 -0
  27. package/dist/functions/version/incrementVersion.js.map +1 -0
  28. package/dist/functions/version/parseVersion.d.ts +4 -0
  29. package/dist/functions/version/parseVersion.js +35 -0
  30. package/dist/functions/version/parseVersion.js.map +1 -0
  31. package/package.json +6 -1
  32. package/references/tencent-cloud.d.ts +65 -0
  33. package/types/semver.d.ts +68 -0
  34. package/types/tencent-cloud.d.ts +44 -0
@@ -0,0 +1,30 @@
1
+ export interface CommandResult {
2
+ exitCode: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ success: boolean;
6
+ }
7
+ export interface Executor {
8
+ exec(command: string, options?: {
9
+ cwd?: string;
10
+ }): CommandResult;
11
+ }
12
+ export interface Logger {
13
+ info(message: string): void;
14
+ error(message: string): void;
15
+ warn(message: string): void;
16
+ debug(message: string): void;
17
+ }
18
+ export interface GitEnvironment {
19
+ installed: boolean;
20
+ version?: string;
21
+ userConfigured: boolean;
22
+ userName?: string;
23
+ userEmail?: string;
24
+ inRepository: boolean;
25
+ }
26
+ export declare function checkGitEnvironment(executor: Executor): GitEnvironment;
27
+ export declare function checkBranch(executor: Executor, logger: Logger, options?: {
28
+ allowedBranches?: string[];
29
+ force?: boolean;
30
+ }): boolean;
@@ -0,0 +1,71 @@
1
+ export function checkGitEnvironment(executor) {
2
+ const result = {
3
+ installed: false,
4
+ userConfigured: false,
5
+ inRepository: false
6
+ };
7
+ const versionResult = executor.exec('git --version');
8
+ if (versionResult.success) {
9
+ result.installed = true;
10
+ result.version = versionResult.stdout.trim().replace('git version ', '');
11
+ }
12
+ else {
13
+ return result;
14
+ }
15
+ const userNameResult = executor.exec('git config user.name');
16
+ const userEmailResult = executor.exec('git config user.email');
17
+ if (userNameResult.success && userEmailResult.success) {
18
+ result.userConfigured = true;
19
+ result.userName = userNameResult.stdout.trim();
20
+ result.userEmail = userEmailResult.stdout.trim();
21
+ }
22
+ const repoResult = executor.exec('git rev-parse --git-dir');
23
+ result.inRepository = repoResult.success;
24
+ return result;
25
+ }
26
+ function getCurrentBranch(executor) {
27
+ const result = executor.exec('git branch --show-current');
28
+ if (!result.success) {
29
+ throw new Error(`获取当前分支失败: ${result.stderr}`);
30
+ }
31
+ return result.stdout.trim();
32
+ }
33
+ export function checkBranch(executor, logger, options = {}) {
34
+ const { allowedBranches = ['main', 'master'], force = false } = options;
35
+ try {
36
+ const gitEnv = checkGitEnvironment(executor);
37
+ if (!gitEnv.installed) {
38
+ logger.error('Git 未安装,请先安装 Git');
39
+ return false;
40
+ }
41
+ if (!gitEnv.userConfigured) {
42
+ logger.error('Git 用户信息未配置,请先配置用户名和邮箱');
43
+ return false;
44
+ }
45
+ if (!gitEnv.inRepository) {
46
+ logger.error('当前目录不是 Git 仓库');
47
+ return false;
48
+ }
49
+ logger.info('检查当前分支...');
50
+ const currentBranch = getCurrentBranch(executor);
51
+ if (!allowedBranches.includes(currentBranch)) {
52
+ const message = `当前在分支 '${currentBranch}',建议在主分支发布`;
53
+ if (force) {
54
+ logger.warn(`${message}(已强制继续)`);
55
+ return true;
56
+ }
57
+ else {
58
+ logger.error(`${message},使用 --force 参数强制发布`);
59
+ return false;
60
+ }
61
+ }
62
+ logger.info(`当前分支: ${currentBranch}`);
63
+ return true;
64
+ }
65
+ catch (error) {
66
+ const errorMessage = error instanceof Error ? error.message : String(error);
67
+ logger.error(`无法获取当前分支信息: ${errorMessage}`);
68
+ return false;
69
+ }
70
+ }
71
+ //# sourceMappingURL=checkBranch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkBranch.js","sourceRoot":"","sources":["../../../src/functions/git/checkBranch.ts"],"names":[],"mappings":"AA2DA,MAAM,UAAU,mBAAmB,CAAC,QAAkB;IACpD,MAAM,MAAM,GAAmB;QAC7B,SAAS,EAAE,KAAK;QAChB,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,KAAK;KACpB,CAAA;IAGD,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IACpD,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,SAAS,GAAG,IAAI,CAAA;QACvB,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,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{ Git } from '../../../references/git.d';
2
+ import type { LogEntry } from '../../../types/publish.d';
3
+ export declare function checkWorkingDirectory(git: Git, logger?: (entry: LogEntry) => void): boolean;
@@ -0,0 +1,41 @@
1
+ export function checkWorkingDirectory(git, logger) {
2
+ try {
3
+ logger?.({
4
+ level: 'info',
5
+ message: '检查 Git 工作目录状态...',
6
+ timestamp: new Date()
7
+ });
8
+ const status = git.status();
9
+ if (!status.clean) {
10
+ const message = '工作目录不干净,请先提交或暂存所有更改';
11
+ logger?.({
12
+ level: 'error',
13
+ message,
14
+ timestamp: new Date(),
15
+ details: {
16
+ staged: status.staged,
17
+ modified: status.modified,
18
+ untracked: status.untracked
19
+ }
20
+ });
21
+ return false;
22
+ }
23
+ logger?.({
24
+ level: 'success',
25
+ message: '工作目录干净',
26
+ timestamp: new Date()
27
+ });
28
+ return true;
29
+ }
30
+ catch (error) {
31
+ const message = '无法检查 Git 状态,请确保在 Git 仓库中运行';
32
+ logger?.({
33
+ level: 'error',
34
+ message,
35
+ timestamp: new Date(),
36
+ details: error
37
+ });
38
+ return false;
39
+ }
40
+ }
41
+ //# sourceMappingURL=checkWorkingDirectory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkWorkingDirectory.js","sourceRoot":"","sources":["../../../src/functions/git/checkWorkingDirectory.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,qBAAqB,CACnC,GAAQ,EACR,MAAkC;IAElC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,kBAAkB;YAC3B,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAA;QAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,qBAAqB,CAAA;YACrC,MAAM,EAAE,CAAC;gBACP,KAAK,EAAE,OAAO;gBACd,OAAO;gBACP,SAAS,EAAE,IAAI,IAAI,EAAE;gBACrB,OAAO,EAAE;oBACP,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;iBAC5B;aACF,CAAC,CAAA;YACF,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,QAAQ;YACjB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,4BAA4B,CAAA;QAC5C,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,OAAO;YACd,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE,KAAK;SACf,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Git } from '../../../references/git.d';
2
+ import type { LogEntry } from '../../../types/publish.d';
3
+ export declare function createGitTag(git: Git, version: string, options?: {
4
+ files?: string[];
5
+ commitMessage?: string;
6
+ tagMessage?: string;
7
+ }, logger?: (entry: LogEntry) => void): boolean;
@@ -0,0 +1,36 @@
1
+ export function createGitTag(git, version, options = {}, logger) {
2
+ const { files = ['package.json'], commitMessage = `chore: bump version to ${version}`, tagMessage = `Release v${version}` } = options;
3
+ try {
4
+ logger?.({
5
+ level: 'info',
6
+ message: '创建 Git 提交和标签...',
7
+ timestamp: new Date()
8
+ });
9
+ git.add(files);
10
+ git.commit(commitMessage);
11
+ git.createTag(`v${version}`, tagMessage);
12
+ logger?.({
13
+ level: 'success',
14
+ message: `已创建标签 v${version}`,
15
+ timestamp: new Date(),
16
+ details: {
17
+ version,
18
+ commitMessage,
19
+ tagMessage,
20
+ files
21
+ }
22
+ });
23
+ return true;
24
+ }
25
+ catch (error) {
26
+ const message = '创建 Git 标签失败';
27
+ logger?.({
28
+ level: 'error',
29
+ message,
30
+ timestamp: new Date(),
31
+ details: error
32
+ });
33
+ return false;
34
+ }
35
+ }
36
+ //# sourceMappingURL=createGitTag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGitTag.js","sourceRoot":"","sources":["../../../src/functions/git/createGitTag.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,YAAY,CAC1B,GAAQ,EACR,OAAe,EACf,UAII,EAAE,EACN,MAAkC;IAElC,MAAM,EACJ,KAAK,GAAG,CAAC,cAAc,CAAC,EACxB,aAAa,GAAG,0BAA0B,OAAO,EAAE,EACnD,UAAU,GAAG,YAAY,OAAO,EAAE,EACnC,GAAG,OAAO,CAAA;IAEX,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAA;QAGF,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAGd,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAGzB,GAAG,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE,EAAE,UAAU,CAAC,CAAA;QAExC,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,UAAU,OAAO,EAAE;YAC5B,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE;gBACP,OAAO;gBACP,aAAa;gBACb,UAAU;gBACV,KAAK;aACN;SACF,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,aAAa,CAAA;QAC7B,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,OAAO;YACd,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE,KAAK;SACf,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ export interface CommandResult {
2
+ exitCode: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ success: boolean;
6
+ }
7
+ export interface ExecOptions {
8
+ cwd?: string;
9
+ env?: Record<string, string>;
10
+ timeout?: number;
11
+ }
12
+ export interface Executor {
13
+ exec(command: string, options?: ExecOptions): CommandResult;
14
+ }
15
+ export interface Logger {
16
+ info(message: string): void;
17
+ error(message: string): void;
18
+ warn(message: string): void;
19
+ debug(message: string): void;
20
+ }
21
+ export interface PushOptions extends ExecOptions {
22
+ remote?: string;
23
+ branch?: string;
24
+ pushTags?: boolean;
25
+ force?: boolean;
26
+ }
27
+ export interface PushResult {
28
+ success: boolean;
29
+ branch: string;
30
+ remote: string;
31
+ tagsPushed: boolean;
32
+ error?: string;
33
+ }
34
+ export declare function pushToRemote(executor: Executor, logger: Logger, options?: PushOptions): Promise<PushResult>;
@@ -0,0 +1,51 @@
1
+ function getCurrentBranch(executor, options) {
2
+ const result = executor.exec('git branch --show-current', options);
3
+ if (!result.success) {
4
+ throw new Error(`获取当前分支失败: ${result.stderr}`);
5
+ }
6
+ return result.stdout.trim();
7
+ }
8
+ export async function pushToRemote(executor, logger, options = {}) {
9
+ const { remote = 'origin', branch, pushTags = false, force = false, ...execOptions } = options;
10
+ try {
11
+ const targetBranch = branch || getCurrentBranch(executor, execOptions);
12
+ logger.info(`开始推送到远程仓库: ${remote}/${targetBranch}`);
13
+ let pushCommand = `git push ${remote} ${targetBranch}`;
14
+ if (force) {
15
+ pushCommand = `git push --force ${remote} ${targetBranch}`;
16
+ }
17
+ const pushResult = executor.exec(pushCommand, execOptions);
18
+ if (!pushResult.success) {
19
+ throw new Error(`推送分支失败: ${pushResult.stderr}`);
20
+ }
21
+ logger.info(`成功推送分支: ${targetBranch}`);
22
+ let tagsPushed = false;
23
+ if (pushTags) {
24
+ const tagCommand = `git push --tags ${remote}`;
25
+ const tagResult = executor.exec(tagCommand, execOptions);
26
+ if (!tagResult.success) {
27
+ throw new Error(`推送标签失败: ${tagResult.stderr}`);
28
+ }
29
+ tagsPushed = true;
30
+ logger.info(`成功推送标签到: ${remote}`);
31
+ }
32
+ return {
33
+ success: true,
34
+ branch: targetBranch,
35
+ remote,
36
+ tagsPushed
37
+ };
38
+ }
39
+ catch (error) {
40
+ const errorMessage = error instanceof Error ? error.message : String(error);
41
+ logger.error(`推送失败: ${errorMessage}`);
42
+ return {
43
+ success: false,
44
+ branch: branch || 'unknown',
45
+ remote,
46
+ tagsPushed: false,
47
+ error: errorMessage
48
+ };
49
+ }
50
+ }
51
+ //# sourceMappingURL=pushToRemote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushToRemote.js","sourceRoot":"","sources":["../../../src/functions/git/pushToRemote.ts"],"names":[],"mappings":"AAqFA,SAAS,gBAAgB,CAAC,QAAkB,EAAE,OAAqB;IACjE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAA;IAClE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;AAC7B,CAAC;AASD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAkB,EAClB,MAAc,EACd,UAAuB,EAAE;IAEzB,MAAM,EACJ,MAAM,GAAG,QAAQ,EACjB,MAAM,EACN,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,KAAK,EACb,GAAG,WAAW,EACf,GAAG,OAAO,CAAA;IAEX,IAAI,CAAC;QAEH,MAAM,YAAY,GAAG,MAAM,IAAI,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;QAEtE,MAAM,CAAC,IAAI,CAAC,cAAc,MAAM,IAAI,YAAY,EA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;YACd,MAAM,EAAE,MAAM,IAAI,SAAS;YAC3B,MAAM;YACN,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,YAAY;SACpB,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -3,4 +3,14 @@ export interface IpcRequest {
3
3
  event: string;
4
4
  args: any;
5
5
  }
6
- export declare function dispatchIpcRequest(req: IpcRequest, functionsDir: string, path: Path): Promise<any>;
6
+ export interface IpcHandlerMap {
7
+ [eventName: string]: {
8
+ default: (...args: any[]) => any | Promise<any>;
9
+ };
10
+ }
11
+ export declare function dispatchIpcRequest(req: IpcRequest, options: {
12
+ handlerMap: IpcHandlerMap;
13
+ } | {
14
+ functionsDir: string;
15
+ path: Path;
16
+ }): Promise<any>;
@@ -1,10 +1,23 @@
1
- export async function dispatchIpcRequest(req, functionsDir, path) {
2
- const funcPath = path.resolve(functionsDir, req.event);
3
- const mod = await import(funcPath);
4
- if (typeof mod.default !== 'function') {
5
- throw new Error('Handler not found or handler is not a function');
1
+ export async function dispatchIpcRequest(req, options) {
2
+ if ('handlerMap' in options) {
3
+ const module = options.handlerMap[req.event];
4
+ if (!module) {
5
+ throw new Error(`Handler not found for event: ${req.event}`);
6
+ }
7
+ if (typeof module.default !== 'function') {
8
+ throw new Error(`Handler for event '${req.event}' is not a function`);
9
+ }
10
+ return await module.default(req.args);
6
11
  }
7
- const data = await mod.default(req.args);
8
- return data;
12
+ if ('functionsDir' in options && 'path' in options) {
13
+ const funcPath = options.path.resolve(options.functionsDir, req.event);
14
+ const mod = await import(funcPath);
15
+ if (typeof mod.default !== 'function') {
16
+ throw new Error('Handler not found or handler is not a function');
17
+ }
18
+ const data = await mod.default(req.args);
19
+ return data;
20
+ }
21
+ throw new Error('Invalid options: must provide either handlerMap or functionsDir with path');
9
22
  }
10
23
  //# sourceMappingURL=dispatchIpcRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatchIpcRequest.js","sourceRoot":"","sources":["../../../src/functions/ipc/dispatchIpcRequest.ts"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CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FileSystem } from '../../../references/node.d';
2
+ import type { PackageInfo, LogEntry } from '../../../types/publish.d';
3
+ export declare function readPackageInfo(fs: FileSystem, packagePath?: string, logger?: (entry: LogEntry) => void): PackageInfo;
@@ -0,0 +1,53 @@
1
+ export function readPackageInfo(fs, packagePath = 'package.json', logger) {
2
+ try {
3
+ logger?.({
4
+ level: 'info',
5
+ message: `读取包信息: ${packagePath}`,
6
+ timestamp: new Date()
7
+ });
8
+ if (!fs.existsSync(packagePath)) {
9
+ throw new Error(`package.json 文件不存在: ${packagePath}`);
10
+ }
11
+ const content = fs.readFileSync(packagePath, 'utf8');
12
+ const packageJson = JSON.parse(content);
13
+ const packageInfo = {
14
+ name: packageJson.name || '',
15
+ version: packageJson.version || '0.0.0',
16
+ description: packageJson.description || '',
17
+ main: packageJson.main,
18
+ scripts: packageJson.scripts || {},
19
+ dependencies: packageJson.dependencies || {},
20
+ devDependencies: packageJson.devDependencies || {},
21
+ peerDependencies: packageJson.peerDependencies || {},
22
+ keywords: packageJson.keywords || [],
23
+ author: packageJson.author,
24
+ license: packageJson.license,
25
+ repository: packageJson.repository,
26
+ bugs: packageJson.bugs,
27
+ homepage: packageJson.homepage,
28
+ private: packageJson.private || false
29
+ };
30
+ logger?.({
31
+ level: 'success',
32
+ message: `已读取包信息: ${packageInfo.name}@${packageInfo.version}`,
33
+ timestamp: new Date(),
34
+ details: {
35
+ name: packageInfo.name,
36
+ version: packageInfo.version,
37
+ private: packageInfo.private
38
+ }
39
+ });
40
+ return packageInfo;
41
+ }
42
+ catch (error) {
43
+ const message = `读取包信息失败: ${packagePath}`;
44
+ logger?.({
45
+ level: 'error',
46
+ message,
47
+ timestamp: new Date(),
48
+ details: error
49
+ });
50
+ throw new Error(message);
51
+ }
52
+ }
53
+ //# sourceMappingURL=readPackageInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPackageInfo.js","sourceRoot":"","sources":["../../../src/functions/package/readPackageInfo.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,eAAe,CAC7B,EAAc,EACd,cAAsB,cAAc,EACpC,MAAkC;IAElC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,UAAU,WAAW,EAAE;YAChC,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,uBAAuB,WAAW,EAAE,CAAC,CAAA;QACvD,CAAC;QAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QACpD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAEvC,MAAM,WAAW,GAAgB;YAC/B,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,EAAE;YAC5B,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,OAAO;YACvC,WAAW,EAAE,WAAW,CAAC,WAAW,IAAI,EAAE;YAC1C,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,EAAE;YAClC,YAAY,EAAE,WAAW,CAAC,YAAY,IAAI,EAAE;YAC5C,eAAe,EAAE,WAAW,CAAC,eAAe,IAAI,EAAE;YAClD,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,IAAI,EAAE;YACpD,QAAQ,EAAE,WAAW,CAAC,QAAQ,IAAI,EAAE;YACpC,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,KAAK;SACtC,CAAA;QAED,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,WAAW,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE;YAC7D,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,OAAO,EAAE,WAAW,CAAC,OAAO;aAC7B;SACF,CAAC,CAAA;QAEF,OAAO,WAAW,CAAA;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,YAAY,WAAW,EAAE,CAAA;QACzC,MAAM,EAAE,CAAC;YACP,KAAK,EAAE,OAAO;YACd,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO,EAAE,KAAK;SACf,CAAC,CAAA;QACF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DeployOptions, DeployResult, DeployDependencies } from '../../../types/tencent-cloud.d';
2
+ export declare function deployToTCB(options: DeployOptions, dependencies: DeployDependencies): Promise<DeployResult>;
3
+ export default deployToTCB;
@@ -0,0 +1,47 @@
1
+ export async function deployToTCB(options, dependencies) {
2
+ const { localPath, cloudPath = '/', envId, secretType, showProgress = true } = options;
3
+ const { cloudBase, path, fs, console, getSecret } = dependencies;
4
+ try {
5
+ if (!fs.existsSync(localPath)) {
6
+ return {
7
+ success: false,
8
+ error: `本地路径不存在: ${localPath}`
9
+ };
10
+ }
11
+ const secret = getSecret(secretType);
12
+ if (!secret || !secret.secretId || !secret.secretKey) {
13
+ return {
14
+ success: false,
15
+ error: `无效的密钥类型: ${secretType}`
16
+ };
17
+ }
18
+ const app = cloudBase.init({
19
+ secretId: secret.secretId,
20
+ secretKey: secret.secretKey,
21
+ envId
22
+ });
23
+ const hosting = app.hosting;
24
+ await hosting.uploadFiles({
25
+ localPath,
26
+ cloudPath,
27
+ onProgress: showProgress ? (progressData) => {
28
+ console.log(`上传进度: ${progressData.percent}%`);
29
+ } : undefined
30
+ });
31
+ console.log('文件上传成功');
32
+ return {
33
+ success: true,
34
+ message: '部署成功'
35
+ };
36
+ }
37
+ catch (error) {
38
+ const errorMessage = error instanceof Error ? error.message : String(error);
39
+ console.error('部署失败:', error);
40
+ return {
41
+ success: false,
42
+ error: `部署失败: ${errorMessage}`
43
+ };
44
+ }
45
+ }
46
+ export default deployToTCB;
47
+ //# sourceMappingURL=deploy.tcb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.tcb.js","sourceRoot":"","sources":["../../../src/functions/tencent-cloud/deploy.tcb.ts"],"names":[],"mappings":"AAwCA,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAsB,EACtB,YAAgC;IAEhC,MAAM,EACJ,SAAS,EACT,SAAS,GAAG,GAAG,EACf,KAAK,EACL,UAAU,EACV,YAAY,GAAG,IAAI,EACpB,GAAG,OAAO,CAAA;IAEX,MAAM,EACJ,SAAS,EACT,IAAI,EACJ,EAAE,EACF,OAAO,EACP,SAAS,EACV,GAAG,YAAY,CAAA;IAEhB,IAAI,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,U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E,SAAS,YAAY,EAAE;SAC/B,CAAA;IACH,CAAC;AACH,CAAC;AAQD,eAAe,WAAW,CAAA"}
@@ -1,6 +1,4 @@
1
- export interface Secret {
2
- secretId: string;
3
- secretKey: string;
4
- }
5
- export type SecretType = 'personal' | 'individual' | 'enterprise';
6
- export declare function getSecret(type: SecretType): Secret;
1
+ import type { TencentCloudSecret } from '../../../references/tencent-cloud.d';
2
+ import type { SecretType } from '../../../types/tencent-cloud.d';
3
+ export declare function getSecret(type: SecretType): TencentCloudSecret;
4
+ export default getSecret;
@@ -15,4 +15,5 @@ const secretMap = {
15
15
  export function getSecret(type) {
16
16
  return secretMap[type];
17
17
  }
18
+ export default getSecret;
18
19
  //# sourceMappingURL=getSecret.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSecret.js","sourceRoot":"","sources":["../../../src/functions/tencent-cloud/getSecret.ts"],"names":[],"mappings":"AAUA,MAAM,SAAS,GAA+B;IAC5C,QAAQ,EAAE;QAER,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;IACD,UAAU,EAAE;QAEV,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;IACD,UAAU,EAAE;QAEV,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;CACF,CAAA;AAiBD,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC"}
1
+ {"version":3,"file":"getSecret.js","sourceRoot":"","sources":["../../../src/functions/tencent-cloud/getSecret.ts"],"names":[],"mappings":"AAIA,MAAM,SAAS,GAA2C;IACxD,QAAQ,EAAE;QAER,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;IACD,UAAU,EAAE;QAEV,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;IACD,UAAU,EAAE;QAEV,QAAQ,EAAE,sCAAsC;QAChD,SAAS,EAAE,kCAAkC;KAC9C;CACF,CAAA;AAoCD,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAKD,eAAe,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { VersionType } from '../../../types/semver.d';
2
+ export declare function incrementVersion(currentVersion: string, type: VersionType, prerelease?: string): string;
3
+ export declare function suggestVersionType(changes: string[]): VersionType;
@@ -0,0 +1,57 @@
1
+ import { parseVersion, stringifyVersion } from './parseVersion';
2
+ export function incrementVersion(currentVersion, type, prerelease) {
3
+ const version = parseVersion(currentVersion);
4
+ switch (type) {
5
+ case 'major':
6
+ return stringifyVersion({
7
+ major: version.major + 1,
8
+ minor: 0,
9
+ patch: 0
10
+ });
11
+ case 'minor':
12
+ return stringifyVersion({
13
+ major: version.major,
14
+ minor: version.minor + 1,
15
+ patch: 0
16
+ });
17
+ case 'patch':
18
+ return stringifyVersion({
19
+ major: version.major,
20
+ minor: version.minor,
21
+ patch: version.patch + 1
22
+ });
23
+ case 'prerelease':
24
+ if (!prerelease) {
25
+ throw new Error('预发布版本需要指定 prerelease 标识符');
26
+ }
27
+ if (version.prerelease) {
28
+ const match = version.prerelease.match(/^(.+?)\.(\d+)$/);
29
+ if (match && match[1] === prerelease) {
30
+ const prereleaseNumber = parseInt(match[2], 10) + 1;
31
+ return stringifyVersion({
32
+ ...version,
33
+ prerelease: `${prerelease}.${prereleaseNumber}`
34
+ });
35
+ }
36
+ }
37
+ return stringifyVersion({
38
+ major: version.major,
39
+ minor: version.minor,
40
+ patch: version.patch + 1,
41
+ prerelease: `${prerelease}.0`
42
+ });
43
+ default:
44
+ throw new Error(`不支持的版本类型: ${type}`);
45
+ }
46
+ }
47
+ export function suggestVersionType(changes) {
48
+ const changeText = changes.join(' ').toLowerCase();
49
+ if (changeText.includes('breaking') || changeText.includes('major')) {
50
+ return 'major';
51
+ }
52
+ if (changeText.includes('feat') || changeText.includes('feature') || changeText.includes('add')) {
53
+ return 'minor';
54
+ }
55
+ return 'patch';
56
+ }
57
+ //# sourceMappingURL=incrementVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incrementVersion.js","sourceRoot":"","sources":["../../../src/functions/version/incrementVersion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAU/D,MAAM,UAAU,gBAAgB,CAC9B,cAAsB,EACtB,IAAiB,EACjB,UAAmB;IAEnB,MAAM,OAAO,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;IAE5C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,gBAAgB,CAAC;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC;gBACxB,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,CAAC;aACT,CAAC,CAAA;QAEJ,KAAK,OAAO;YACV,OAAO,gBAAgB,CAAC;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC;gBACxB,KAAK,EAAE,CAAC;aACT,CAAC,CAAA;QAEJ,KAAK,OAAO;YACV,OAAO,gBAAgB,CAAC;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC;aACzB,CAAC,CAAA;QAEJ,KAAK,YAAY;YACf,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YAC7C,CAAC;YAGD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;gBACxD,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;oBACrC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;oBACnD,OAAO,gBAAgB,CAAC;wBACtB,GAAG,OAAO;wBACV,UAAU,EAAE,GAAG,UAAU,IAAI,gBAAgB,EAAE;qBAChD,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;YAGD,OAAO,gBAAgB,CAAC;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC;gBACxB,UAAU,EAAE,GAAG,UAAU,IAAI;aAC9B,CAAC,CAAA;QAEJ;YACE,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;AACH,CAAC;AAQD,MAAM,UAAU,kBAAkB,CAAC,OAAiB;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAGlD,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpE,OAAO,OAAO,CAAA;IAChB,CAAC;IAGD,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAChG,OAAO,OAAO,CAAA;IAChB,CAAC;IAGD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Version } from '../../../types/semver.d';
2
+ export declare function parseVersion(version: string): Version;
3
+ export declare function stringifyVersion(version: Version): string;
4
+ export declare function compareVersions(a: Version, b: Version): number;
@@ -0,0 +1,35 @@
1
+ export function parseVersion(version) {
2
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
3
+ if (!match) {
4
+ throw new Error(`无效的版本号格式: ${version}`);
5
+ }
6
+ return {
7
+ major: parseInt(match[1], 10),
8
+ minor: parseInt(match[2], 10),
9
+ patch: parseInt(match[3], 10),
10
+ prerelease: match[4]
11
+ };
12
+ }
13
+ export function stringifyVersion(version) {
14
+ const base = `${version.major}.${version.minor}.${version.patch}`;
15
+ return version.prerelease ? `${base}-${version.prerelease}` : base;
16
+ }
17
+ export function compareVersions(a, b) {
18
+ if (a.major !== b.major) {
19
+ return a.major > b.major ? 1 : -1;
20
+ }
21
+ if (a.minor !== b.minor) {
22
+ return a.minor > b.minor ? 1 : -1;
23
+ }
24
+ if (a.patch !== b.patch) {
25
+ return a.patch > b.patch ? 1 : -1;
26
+ }
27
+ if (a.prerelease && !b.prerelease)
28
+ return -1;
29
+ if (!a.prerelease && b.prerelease)
30
+ return 1;
31
+ if (!a.prerelease && !b.prerelease)
32
+ return 0;
33
+ return a.prerelease > b.prerelease ? 1 : (a.prerelease < b.prerelease ? -1 : 0);
34
+ }
35
+ //# sourceMappingURL=parseVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseVersion.js","sourceRoot":"","sources":["../../../src/functions/version/parseVersion.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAA;IAE9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,aAAa,OAAO,EAAE,CAAC,CAAA;IACzC,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,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U;QAAE,OAAO,CAAC,CAAA;IAG5C,OAAO,CAAC,CAAC,UAAW,GAAG,CAAC,CAAC,UAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAW,GAAG,CAAC,CAAC,UAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcw-shared",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "files": [
5
5
  "references",
6
6
  "dist",
@@ -66,6 +66,7 @@
66
66
  "./functions/string/similarity": "./dist/functions/string/similarity.js",
67
67
  "./functions/string/template": "./dist/functions/string/template.js",
68
68
  "./functions/string/wordCount": "./dist/functions/string/wordCount.js",
69
+ "./functions/tencent-cloud/deploy.tcb": "./dist/functions/tencent-cloud/deploy.tcb.js",
69
70
  "./functions/tencent-cloud/getSecret": "./dist/functions/tencent-cloud/getSecret.js",
70
71
  "./functions/uniapp/app-plus/buildAndroidApp": "./dist/functions/uniapp/app-plus/buildAndroidApp.js",
71
72
  "./functions/uniapp/build": "./dist/functions/uniapp/build.js",
@@ -91,6 +92,8 @@
91
92
  "./functions/utils/until": "./dist/functions/utils/until.js",
92
93
  "./functions/utils/validate": "./dist/functions/utils/validate.js",
93
94
  "./functions/utils/walk": "./dist/functions/utils/walk.js",
95
+ "./functions/version/incrementVersion": "./dist/functions/version/incrementVersion.js",
96
+ "./functions/version/parseVersion": "./dist/functions/version/parseVersion.js",
94
97
  "./functions/vue/dynamicMount": "./dist/functions/vue/dynamicMount.js",
95
98
  "./functions/vue/extractColorsFromVueFile": "./dist/functions/vue/extractColorsFromVueFile.js",
96
99
  "./functions/vue/extractColorsFromVueSection": "./dist/functions/vue/extractColorsFromVueSection.js",
@@ -116,8 +119,10 @@
116
119
  "./types/design-system": "./types/design-system.d.ts",
117
120
  "./types/geometry": "./types/geometry.d.ts",
118
121
  "./types/platform": "./types/platform.d.ts",
122
+ "./types/semver": "./types/semver.d.ts",
119
123
  "./types/software": "./types/software.d.ts",
120
124
  "./types/storage": "./types/storage.d.ts",
125
+ "./types/tencent-cloud": "./types/tencent-cloud.d.ts",
121
126
  "./types/uniapp-android-build": "./types/uniapp-android-build.d.ts",
122
127
  "./types/vue": "./types/vue.d.ts",
123
128
  "./types/worker": "./types/worker.d.ts"
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 腾讯云相关类型定义
3
+ *
4
+ * @description
5
+ * 定义腾讯云服务相关的接口和类型,用于依赖注入
6
+ * 确保函数的环境无关性
7
+ *
8
+ * @since 1.0.0
9
+ * @author Assistant
10
+ */
11
+
12
+ import type { Console } from './console.d'
13
+ import type { FileSystem, Path, Process } from './node.d'
14
+
15
+ // 腾讯云密钥接口
16
+ export interface TencentCloudSecret {
17
+ secretId: string
18
+ secretKey: string
19
+ }
20
+
21
+ // 腾讯云配置接口
22
+ export interface TencentCloudConfig {
23
+ secretId: string
24
+ secretKey: string
25
+ envId: string
26
+ }
27
+
28
+ // 上传进度数据
29
+ export interface UploadProgressData {
30
+ percent: number
31
+ loaded: number
32
+ total: number
33
+ }
34
+
35
+ // 上传文件选项
36
+ export interface UploadFilesOptions {
37
+ localPath: string
38
+ cloudPath: string
39
+ onProgress?: (progressData: UploadProgressData) => void
40
+ }
41
+
42
+ // 静态网站托管服务接口
43
+ export interface HostingService {
44
+ uploadFiles(options: UploadFilesOptions): Promise<void>
45
+ }
46
+
47
+ // CloudBase 应用接口
48
+ export interface CloudBaseApp {
49
+ hosting: HostingService
50
+ }
51
+
52
+ // CloudBase 管理器接口
53
+ export interface CloudBaseManager {
54
+ init(config: TencentCloudConfig): CloudBaseApp
55
+ }
56
+
57
+ // 腾讯云系统依赖接口
58
+ export interface TencentCloudSystemDependencies {
59
+ cloudBase: CloudBaseManager
60
+ path: Path
61
+ fs: FileSystem
62
+ process: Process
63
+ console: Console
64
+ getSecret: (type: string) => TencentCloudSecret
65
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Semantic Versioning (SemVer) 类型定义
3
+ * 遵循 https://semver.org/ 规范
4
+ */
5
+
6
+ /**
7
+ * 版本递增类型
8
+ */
9
+ export type VersionType = 'major' | 'minor' | 'patch' | 'prerelease'
10
+
11
+ /**
12
+ * 语义化版本对象
13
+ */
14
+ export interface Version {
15
+ /** 主版本号 - 不兼容的 API 修改 */
16
+ major: number
17
+ /** 次版本号 - 向下兼容的功能性新增 */
18
+ minor: number
19
+ /** 修订号 - 向下兼容的问题修正 */
20
+ patch: number
21
+ /** 预发布版本标识符 */
22
+ prerelease?: string
23
+ }
24
+
25
+ /**
26
+ * 版本比较结果
27
+ */
28
+ export type VersionComparison = -1 | 0 | 1
29
+
30
+ /**
31
+ * 版本范围操作符
32
+ */
33
+ export type VersionRangeOperator =
34
+ | '^' // 兼容版本(不改变主版本号)
35
+ | '~' // 近似版本(不改变主次版本号)
36
+ | '>=' // 大于等于
37
+ | '>' // 大于
38
+ | '<=' // 小于等于
39
+ | '<' // 小于
40
+ | '=' // 等于
41
+
42
+ /**
43
+ * 版本范围
44
+ */
45
+ export interface VersionRange {
46
+ operator: VersionRangeOperator
47
+ version: string
48
+ }
49
+
50
+ /**
51
+ * 版本解析选项
52
+ */
53
+ export interface VersionParseOptions {
54
+ /** 是否允许前缀 'v' */
55
+ allowPrefix?: boolean
56
+ /** 是否严格模式(严格遵循 SemVer 规范) */
57
+ strict?: boolean
58
+ }
59
+
60
+ /**
61
+ * 版本递增选项
62
+ */
63
+ export interface VersionIncrementOptions {
64
+ /** 预发布标识符(如 'alpha', 'beta', 'rc') */
65
+ prerelease?: string
66
+ /** 预发布版本号 */
67
+ prereleaseNumber?: number
68
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 腾讯云相关应用层类型定义
3
+ *
4
+ * @description
5
+ * 定义腾讯云部署功能使用的接口和类型
6
+ * 不包含环境相关的类型,环境相关类型请从 references/tencent-cloud.d 导入
7
+ *
8
+ * @since 1.0.0
9
+ * @author Assistant
10
+ */
11
+
12
+ import type {
13
+ TencentCloudSystemDependencies,
14
+ TencentCloudSecret
15
+ } from '../references/tencent-cloud.d'
16
+
17
+ // 密钥类型
18
+ export type SecretType = 'personal' | 'individual' | 'enterprise'
19
+
20
+ // 部署配置选项
21
+ export interface DeployOptions {
22
+ /** 本地文件路径 */
23
+ localPath: string
24
+ /** 云端路径 */
25
+ cloudPath?: string
26
+ /** 环境ID */
27
+ envId: string
28
+ /** 密钥类型 */
29
+ secretType: SecretType
30
+ /** 是否显示进度 */
31
+ showProgress?: boolean
32
+ }
33
+
34
+ // 部署结果
35
+ export interface DeployResult {
36
+ success: boolean
37
+ message?: string
38
+ error?: string
39
+ }
40
+
41
+ // 部署函数依赖接口
42
+ export interface DeployDependencies extends TencentCloudSystemDependencies {
43
+ // 可以扩展特定于部署功能的依赖
44
+ }