@hecom/codearts 0.1.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.
- package/.env.example +20 -0
- package/README.md +228 -0
- package/bin/codearts +2 -0
- package/dist/bin/cli.d.ts +2 -0
- package/dist/bin/cli.js +137 -0
- package/dist/commands/config.command.d.ts +5 -0
- package/dist/commands/config.command.js +109 -0
- package/dist/commands/daily.command.d.ts +10 -0
- package/dist/commands/daily.command.js +184 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/work-hour.command.d.ts +5 -0
- package/dist/commands/work-hour.command.js +153 -0
- package/dist/config/holidays.d.ts +60 -0
- package/dist/config/holidays.js +177 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -0
- package/dist/services/api.service.d.ts +98 -0
- package/dist/services/api.service.js +405 -0
- package/dist/services/business.service.d.ts +69 -0
- package/dist/services/business.service.js +330 -0
- package/dist/types/index.d.ts +522 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/config-loader.d.ts +22 -0
- package/dist/utils/config-loader.js +56 -0
- package/dist/utils/global-config.d.ts +24 -0
- package/dist/utils/global-config.js +153 -0
- package/package.json +70 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getGlobalConfigPath = getGlobalConfigPath;
|
|
37
|
+
exports.globalConfigExists = globalConfigExists;
|
|
38
|
+
exports.readGlobalConfig = readGlobalConfig;
|
|
39
|
+
exports.writeGlobalConfig = writeGlobalConfig;
|
|
40
|
+
exports.deleteGlobalConfig = deleteGlobalConfig;
|
|
41
|
+
exports.getConfigInfo = getConfigInfo;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
/**
|
|
46
|
+
* 全局配置管理工具
|
|
47
|
+
* 配置文件存储在用户主目录下的 .hecom-codearts 目录
|
|
48
|
+
*/
|
|
49
|
+
const CONFIG_DIR = path.join(os.homedir(), '.hecom-codearts');
|
|
50
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
51
|
+
/**
|
|
52
|
+
* 确保配置目录存在
|
|
53
|
+
*/
|
|
54
|
+
function ensureConfigDir() {
|
|
55
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
56
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 获取全局配置文件路径
|
|
61
|
+
*/
|
|
62
|
+
function getGlobalConfigPath() {
|
|
63
|
+
return CONFIG_FILE;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 检查全局配置文件是否存在
|
|
67
|
+
*/
|
|
68
|
+
function globalConfigExists() {
|
|
69
|
+
return fs.existsSync(CONFIG_FILE);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 读取全局配置
|
|
73
|
+
*/
|
|
74
|
+
function readGlobalConfig() {
|
|
75
|
+
if (!globalConfigExists()) {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
const config = {};
|
|
79
|
+
try {
|
|
80
|
+
const content = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
81
|
+
const lines = content.split('\n');
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
const trimmedLine = line.trim();
|
|
84
|
+
if (!trimmedLine || trimmedLine.startsWith('#')) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const equalIndex = trimmedLine.indexOf('=');
|
|
88
|
+
if (equalIndex > 0) {
|
|
89
|
+
const key = trimmedLine.substring(0, equalIndex).trim();
|
|
90
|
+
const value = trimmedLine.substring(equalIndex + 1).trim();
|
|
91
|
+
config[key] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error('读取全局配置文件失败:', error);
|
|
97
|
+
}
|
|
98
|
+
return config;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 写入全局配置
|
|
102
|
+
*/
|
|
103
|
+
function writeGlobalConfig(config) {
|
|
104
|
+
ensureConfigDir();
|
|
105
|
+
const content = `# Hecom CodeArts 全局配置文件
|
|
106
|
+
# 此文件由 codearts config 命令自动生成
|
|
107
|
+
# 位置: ${CONFIG_FILE}
|
|
108
|
+
|
|
109
|
+
# 华为云IAM认证端点(根据区域调整)
|
|
110
|
+
HUAWEI_CLOUD_IAM_ENDPOINT=${config.iamEndpoint || ''}
|
|
111
|
+
HUAWEI_CLOUD_REGION=${config.region || ''}
|
|
112
|
+
|
|
113
|
+
# IAM用户凭证
|
|
114
|
+
HUAWEI_CLOUD_USERNAME=${config.username || ''}
|
|
115
|
+
HUAWEI_CLOUD_PASSWORD=${config.password || ''}
|
|
116
|
+
HUAWEI_CLOUD_DOMAIN=${config.domain || ''}
|
|
117
|
+
|
|
118
|
+
# 项目配置
|
|
119
|
+
CODEARTS_BASE_URL=${config.codeartsUrl || ''}
|
|
120
|
+
PROJECT_ID=${config.projectId || ''}
|
|
121
|
+
ROLE_ID=${config.roleId || ''}
|
|
122
|
+
`;
|
|
123
|
+
try {
|
|
124
|
+
fs.writeFileSync(CONFIG_FILE, content, 'utf-8');
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new Error(`写入全局配置文件失败: ${error}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 删除全局配置
|
|
132
|
+
*/
|
|
133
|
+
function deleteGlobalConfig() {
|
|
134
|
+
if (globalConfigExists()) {
|
|
135
|
+
try {
|
|
136
|
+
fs.unlinkSync(CONFIG_FILE);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new Error(`删除全局配置文件失败: ${error}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 获取配置信息(用于显示)
|
|
145
|
+
*/
|
|
146
|
+
function getConfigInfo() {
|
|
147
|
+
if (globalConfigExists()) {
|
|
148
|
+
return `全局配置文件: ${CONFIG_FILE}`;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
return `全局配置文件不存在\n建议运行: codearts config`;
|
|
152
|
+
}
|
|
153
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hecom/codearts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "从CodeArts获取日报信息",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"codearts": "./bin/codearts"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"bin",
|
|
13
|
+
".env.example",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -rf dist && tsc && chmod +x bin/codearts",
|
|
18
|
+
"test": "jest --passWithNoTests",
|
|
19
|
+
"test:coverage": "jest --coverage --passWithNoTests",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"huawei-cloud",
|
|
24
|
+
"codearts",
|
|
25
|
+
"work-hour",
|
|
26
|
+
"daily-report",
|
|
27
|
+
"cli",
|
|
28
|
+
"typescript",
|
|
29
|
+
"api",
|
|
30
|
+
"statistics"
|
|
31
|
+
],
|
|
32
|
+
"author": "summer88123",
|
|
33
|
+
"license": "ISC",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/hecom-rn/hecom-codearts.git"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/hecom-rn/hecom-codearts#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/hecom-rn/hecom-codearts/issues"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=16.0.0",
|
|
44
|
+
"npm": ">=7.0.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"axios": "^1.5.0",
|
|
48
|
+
"commander": "^12.1.0",
|
|
49
|
+
"dotenv": "^16.3.1",
|
|
50
|
+
"inquirer": "^9.3.8"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/commander": "^2.12.0",
|
|
54
|
+
"@types/inquirer": "^9.0.9",
|
|
55
|
+
"@types/jest": "^29.5.5",
|
|
56
|
+
"@types/node": "^20.6.3",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
|
58
|
+
"@typescript-eslint/parser": "^6.7.2",
|
|
59
|
+
"eslint": "^8.49.0",
|
|
60
|
+
"eslint-config-prettier": "^9.0.0",
|
|
61
|
+
"eslint-config-standard": "^17.1.0",
|
|
62
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
63
|
+
"jest": "^29.7.0",
|
|
64
|
+
"prettier": "^3.0.3",
|
|
65
|
+
"rimraf": "^5.0.1",
|
|
66
|
+
"ts-jest": "^29.1.1",
|
|
67
|
+
"ts-node": "^10.9.1",
|
|
68
|
+
"typescript": "^5.2.2"
|
|
69
|
+
}
|
|
70
|
+
}
|