apipost-cli 1.0.18 → 1.0.19
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/dist/apipost-reports/apipost-reports-2024-04-03_16-47-21.html +750 -0
- package/dist/apipost-reports/apipost-reports-2024-04-03_164706.html +750 -0
- package/dist/apipost-reports/apipost-reports-2024-04-03_16:46:19.html +750 -0
- package/dist/build/Release/cpufeatures.node +0 -0
- package/dist/index.js +124 -18
- package/dist/lib/protocol/crypto/build/Release/sshcrypto.node +0 -0
- package/package.json +1 -2
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -777,7 +777,7 @@ const RENDER_TEST_REPORT_HTML_STR = (data = {}) => {
|
|
|
777
777
|
const downloadTestReport = async (data, options, request) => {
|
|
778
778
|
const homedir = os.homedir();
|
|
779
779
|
const now = dayjs();
|
|
780
|
-
const formattedTime = now.format('YYYY-MM-
|
|
780
|
+
const formattedTime = now.format('YYYY-MM-DD_HH-mm-ss');
|
|
781
781
|
|
|
782
782
|
//检查options.outDir 是否存在,是否是目录
|
|
783
783
|
if (!fs.existsSync(options.outDir)) {
|
|
@@ -801,6 +801,7 @@ const downloadTestReport = async (data, options, request) => {
|
|
|
801
801
|
let retries = 0;
|
|
802
802
|
|
|
803
803
|
for (let i = 0; i < 2; i++) {
|
|
804
|
+
console.log(finalFilePath);
|
|
804
805
|
try {
|
|
805
806
|
fs.writeFileSync(finalFilePath, reportContent);
|
|
806
807
|
break;
|
|
@@ -127305,6 +127306,121 @@ var setObjValByPath = function (obj, val, path) {
|
|
|
127305
127306
|
}, obj);
|
|
127306
127307
|
};
|
|
127307
127308
|
|
|
127309
|
+
/**
|
|
127310
|
+
* 雪花算法生成唯一ID
|
|
127311
|
+
*/
|
|
127312
|
+
/**
|
|
127313
|
+
* 生成 Snowflake ID
|
|
127314
|
+
* @param seed - 用于生成 Snowflake ID 的种子字符串,如果为空,自动生成。建议使用项目id
|
|
127315
|
+
* @param base - hash范围,2或16,2进制或16进制
|
|
127316
|
+
* @returns 以2进制或16进制表示的64位ID
|
|
127317
|
+
*/
|
|
127318
|
+
var snowflakeId = function (seed, base) {
|
|
127319
|
+
if (seed === void 0) { seed = ""; }
|
|
127320
|
+
if (base === void 0) { base = 16; }
|
|
127321
|
+
//base 支持2,16 需要验证
|
|
127322
|
+
base = (base === 2 || base === 16) ? base : 16;
|
|
127323
|
+
seed = seed || genSeed();
|
|
127324
|
+
if (typeof seed !== 'string') {
|
|
127325
|
+
seed = seed + ""; //强制转字符串
|
|
127326
|
+
}
|
|
127327
|
+
var sequence = next_id(); //一直自增id
|
|
127328
|
+
var timestamp = new Date().getTime() - 1671537188000; //和后端约定时间戳起始时间,2022-12-20
|
|
127329
|
+
if (sequence > 4095) {
|
|
127330
|
+
sequence = sequence % 4095; //12位序列号
|
|
127331
|
+
}
|
|
127332
|
+
// 64位ID的划分
|
|
127333
|
+
// 0 - 41位时间戳 - 12位序列号 - 10位机器标识 - 12位序号
|
|
127334
|
+
var binstring = '0' + leftpad(dec2bin(timestamp), 41) + "1" + simpleHash(seed) + leftpad(dec2bin(sequence), 12);
|
|
127335
|
+
if (base === 2) {
|
|
127336
|
+
return binstring;
|
|
127337
|
+
}
|
|
127338
|
+
else {
|
|
127339
|
+
var chunks = splitN(binstring, 4);
|
|
127340
|
+
var binHexMap_1 = { "0000": "0", "0001": "1", "0010": "2", "0011": "3", "0100": "4", "0101": "5", "0110": "6", "0111": "7", "1000": "8", "1001": "9", "1010": "a", "1011": "b", "1100": "c", "1101": "d", "1110": "e", "1111": "f" };
|
|
127341
|
+
//用map转换chunks
|
|
127342
|
+
var hexChunks = chunks.map(function (item) {
|
|
127343
|
+
return binHexMap_1[item];
|
|
127344
|
+
});
|
|
127345
|
+
//返回16进制
|
|
127346
|
+
return hexChunks.join("").replace(/^0+/, '');
|
|
127347
|
+
}
|
|
127348
|
+
//10进制转2进制
|
|
127349
|
+
function dec2bin(dec) {
|
|
127350
|
+
return (dec >>> 0).toString(2);
|
|
127351
|
+
}
|
|
127352
|
+
//左边补0
|
|
127353
|
+
function leftpad(str, len) {
|
|
127354
|
+
str = str + '';
|
|
127355
|
+
len = len - str.length;
|
|
127356
|
+
if (len <= 0) {
|
|
127357
|
+
return str;
|
|
127358
|
+
}
|
|
127359
|
+
return Array(len + 1).join('0') + str;
|
|
127360
|
+
}
|
|
127361
|
+
//右边补0
|
|
127362
|
+
function rightpad(str, len) {
|
|
127363
|
+
str = str + '';
|
|
127364
|
+
len = len - str.length;
|
|
127365
|
+
if (len <= 0) {
|
|
127366
|
+
return str;
|
|
127367
|
+
}
|
|
127368
|
+
return str + Array(len + 1).join('0');
|
|
127369
|
+
}
|
|
127370
|
+
//9位hash
|
|
127371
|
+
function simpleHash(str) {
|
|
127372
|
+
var hash = 0;
|
|
127373
|
+
for (var i = 0; i < str.length; i++) {
|
|
127374
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
127375
|
+
}
|
|
127376
|
+
var strhash = rightpad(dec2bin(hash), 9);
|
|
127377
|
+
if (strhash.length > 9) {
|
|
127378
|
+
strhash = strhash.substring(0, 9);
|
|
127379
|
+
}
|
|
127380
|
+
return strhash;
|
|
127381
|
+
}
|
|
127382
|
+
//gen seed
|
|
127383
|
+
function genSeed() {
|
|
127384
|
+
var seed = "";
|
|
127385
|
+
try {
|
|
127386
|
+
//默认使用进程id
|
|
127387
|
+
//@ts-ignore
|
|
127388
|
+
if (typeof process === 'object' && process + '' === '[object process]') {
|
|
127389
|
+
//@ts-ignore
|
|
127390
|
+
seed = process.pid + "";
|
|
127391
|
+
}
|
|
127392
|
+
else if (typeof window === 'object' && window.navigator && window.navigator.userAgent) {
|
|
127393
|
+
seed = window.navigator.userAgent + window.navigator.language + window.screen.colorDepth + window.screen.width + window.screen.height;
|
|
127394
|
+
}
|
|
127395
|
+
}
|
|
127396
|
+
catch (e) { }
|
|
127397
|
+
//如果为空,生成32位随机字符串
|
|
127398
|
+
if (!seed) {
|
|
127399
|
+
var str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
127400
|
+
for (var i = 0; i < 32; i++) {
|
|
127401
|
+
seed += str.charAt(Math.floor(Math.random() * str.length));
|
|
127402
|
+
}
|
|
127403
|
+
}
|
|
127404
|
+
return seed;
|
|
127405
|
+
}
|
|
127406
|
+
//切分字符串
|
|
127407
|
+
function splitN(inputString, chunkSize) {
|
|
127408
|
+
var chunks = [];
|
|
127409
|
+
for (var i = 0; i < inputString.length; i += chunkSize) {
|
|
127410
|
+
chunks.push(inputString.substring(i, i + chunkSize));
|
|
127411
|
+
}
|
|
127412
|
+
return chunks;
|
|
127413
|
+
}
|
|
127414
|
+
};
|
|
127415
|
+
var generateIncrementalFunction = function () {
|
|
127416
|
+
var counter = 0;
|
|
127417
|
+
return function () {
|
|
127418
|
+
return counter++;
|
|
127419
|
+
};
|
|
127420
|
+
};
|
|
127421
|
+
//生成唯一id
|
|
127422
|
+
var next_id = generateIncrementalFunction();
|
|
127423
|
+
|
|
127308
127424
|
var index = {
|
|
127309
127425
|
isJson: isJson,
|
|
127310
127426
|
isJsonp: isJsonp,
|
|
@@ -127326,6 +127442,7 @@ var index = {
|
|
|
127326
127442
|
completionHttpProtocol: completionHttpProtocol,
|
|
127327
127443
|
NewURL: NewURL,
|
|
127328
127444
|
setObjValByPath: setObjValByPath,
|
|
127445
|
+
snowflakeId: snowflakeId,
|
|
127329
127446
|
};
|
|
127330
127447
|
|
|
127331
127448
|
exports.NewURL = NewURL;
|
|
@@ -127348,6 +127465,7 @@ exports.isXml = isXml;
|
|
|
127348
127465
|
exports.jsonp2Obj = jsonp2Obj;
|
|
127349
127466
|
exports.ms2second = ms2second;
|
|
127350
127467
|
exports.setObjValByPath = setObjValByPath;
|
|
127468
|
+
exports.snowflakeId = snowflakeId;
|
|
127351
127469
|
exports.successResult = successResult;
|
|
127352
127470
|
|
|
127353
127471
|
|
|
@@ -549500,7 +549618,6 @@ const path = __nccwpck_require__(71017);
|
|
|
549500
549618
|
const program = new Command();
|
|
549501
549619
|
const homedir = os.homedir();
|
|
549502
549620
|
const request = __nccwpck_require__(48699);
|
|
549503
|
-
const JSON5 = __nccwpck_require__(86904);
|
|
549504
549621
|
let now = dayjs();
|
|
549505
549622
|
let formattedTime = now.format('YYYY-MM-DD HH:mm:ss');
|
|
549506
549623
|
|
|
@@ -549526,7 +549643,7 @@ let last_msg = "";
|
|
|
549526
549643
|
const currentWorkingDirectory = process.cwd();
|
|
549527
549644
|
const cliOption = {
|
|
549528
549645
|
reporters: 'cli',
|
|
549529
|
-
outDir:
|
|
549646
|
+
outDir: __nccwpck_require__.ab + "apipost-reports",
|
|
549530
549647
|
outFile: '',
|
|
549531
549648
|
iterationData: '',
|
|
549532
549649
|
iterationCount: 1,
|
|
@@ -549720,11 +549837,9 @@ const parseCommandString = async (url, options) => {
|
|
|
549720
549837
|
const data = fs.readFileSync(url, 'utf8');
|
|
549721
549838
|
runData = JSON.parse(data);
|
|
549722
549839
|
} catch (err) {
|
|
549723
|
-
|
|
549724
|
-
|
|
549725
|
-
|
|
549726
|
-
fs.appendFileSync(path.join(homedir, 'apipost-cli-error.log'), `${formattedTime}\t读取本地文件失败, 原因 [${err.message}]\n`);
|
|
549727
|
-
return;
|
|
549840
|
+
console.log(`读取本地文件失败, 原因 [${err.message}]`);
|
|
549841
|
+
fs.appendFileSync(path.join(homedir, 'apipost-cli-error.log'), `${formattedTime}\t读取本地文件失败, 原因 [${err.message}]\n`);
|
|
549842
|
+
return;
|
|
549728
549843
|
}
|
|
549729
549844
|
}else{
|
|
549730
549845
|
//增加https 证书忽略
|
|
@@ -549734,7 +549849,7 @@ const parseCommandString = async (url, options) => {
|
|
|
549734
549849
|
}
|
|
549735
549850
|
|
|
549736
549851
|
if (_.has(runData, 'code')) {
|
|
549737
|
-
if (runData.code
|
|
549852
|
+
if (runData.code === 10000 && _.isObject(_.get(runData, 'data'))) {
|
|
549738
549853
|
runData = _.get(runData, 'data');
|
|
549739
549854
|
} else {
|
|
549740
549855
|
console.log(`执行失败, 原因 [${runData.msg}]`);
|
|
@@ -549786,15 +549901,6 @@ const bindEvent = (program) => {
|
|
|
549786
549901
|
program.parse();
|
|
549787
549902
|
}
|
|
549788
549903
|
|
|
549789
|
-
function fixJsonString(jsonString) {
|
|
549790
|
-
// 正则: 匹配冒号后不是空白符或双引号的任何字符序列
|
|
549791
|
-
const regex = /":([\w|@|\.]+),/g;
|
|
549792
|
-
// 将匹配到的值用双引号括起来
|
|
549793
|
-
const fixedString = jsonString.replace(regex, '":"$1",');
|
|
549794
|
-
|
|
549795
|
-
return fixedString;
|
|
549796
|
-
}
|
|
549797
|
-
|
|
549798
549904
|
const init = () => {
|
|
549799
549905
|
bindEvent(program);
|
|
549800
549906
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apipost-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "Apipost 命令行运行工具",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"author": "Apipost Team",
|
|
20
20
|
"license": "UNLICENSED",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"json5": "^2.2.3"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
"@vercel/ncc": "^0.38.1",
|