🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@antdigital/cube-cli-shared

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antdigital/cube-cli-shared - npm Package Compare versions

Comparing version
4.7.13
to
4.7.14
+0
-1
lib/utils/index.d.ts

@@ -1,2 +0,1 @@

export * from './AFTSUtil';
export * from './camelize';

@@ -3,0 +2,0 @@ export * from './capnp';

@@ -17,3 +17,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./AFTSUtil"), exports);
__exportStar(require("./camelize"), exports);

@@ -20,0 +19,0 @@ __exportStar(require("./capnp"), exports);

+3
-4
{
"name": "@antdigital/cube-cli-shared",
"version": "4.7.13",
"version": "4.7.14",
"main": "lib/index.js",

@@ -13,3 +13,4 @@ "files": [

"publishConfig": {
"registry": "https://registry.npmjs.org"
"registry": "https://registry.npmjs.org",
"access": "public"
},

@@ -24,4 +25,2 @@ "scripts": {

"dependencies": {
"@alipay/afts-sdk": "^1.2.13",
"@alipay/yuyan-common-util": "^4.14.6",
"axios": "^1.7.7",

@@ -28,0 +27,0 @@ "chalk": "^4.1.2",

interface ICardBlockAFTSResult {
md5: string;
fileId: string;
mockMd5: string;
mockFileId: string;
fileList: {
fileId: string;
md5: string;
name: string;
}[];
}
export declare class AFTSUtil {
static upload(distPath: string): Promise<ICardBlockAFTSResult>;
}
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AFTSUtil = void 0;
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const fast_glob_1 = require("fast-glob");
const afts_sdk_1 = __importDefault(require("@alipay/afts-sdk"));
const yuyan_common_util_1 = require("@alipay/yuyan-common-util");
const logger_1 = require("./logger");
class AFTSUtil {
static async upload(distPath) {
let aftsConfig = {
appId: 'apwallet',
bizKey: 'card_playground',
bizSecret: 'd670045d2cc547ce91ef904b57ec6620',
env: 'dev',
};
switch (process.env.NODE_ENV) {
case 'development':
aftsConfig = {
...aftsConfig,
bizSecret: 'd670045d2cc547ce91ef904b57ec6620',
env: 'dev',
};
break;
case 'sit':
aftsConfig = {
...aftsConfig,
bizSecret: 'e684bb47a2da4117a5482aed381cda05',
env: 'sit',
};
break;
case 'production':
aftsConfig = {
...aftsConfig,
bizSecret: '8b21376b03814a6e898391dbd090cb71',
env: 'prod',
};
break;
default:
aftsConfig = {
...aftsConfig,
bizSecret: '8b21376b03814a6e898391dbd090cb71',
env: 'prod',
};
}
const zstPaths = await (0, fast_glob_1.glob)([`${distPath}/**/*.zst`], {
cwd: distPath,
});
const binPaths = await (0, fast_glob_1.glob)([`${distPath}/**/*.bin`], {
cwd: distPath,
});
const mockPaths = await (0, fast_glob_1.glob)([`${distPath}/**/*.mock`], {
cwd: distPath,
});
if (zstPaths.length === 0) {
throw new Error(`${distPath} 中不包含任何 .zst 文件,请检查卡片构建产物`);
}
if (zstPaths.length > 1) {
throw new Error(`${distPath} 中包含多个 .zst 文件,请检查卡片构建产物,不支持同时上传多张卡片`);
}
const artifactPathList = [...zstPaths, ...binPaths, ...mockPaths].map((p) => {
return {
name: node_path_1.default.parse(p).name,
extName: node_path_1.default.extname(p),
fullName: node_path_1.default.basename(p),
fullPath: p,
};
});
logger_1.logger.debug('artifactPathList', artifactPathList, aftsConfig);
const afts = new afts_sdk_1.default({
appId: aftsConfig.appId,
bizKey: aftsConfig.bizKey,
bizSecret: aftsConfig.bizSecret,
}, {
env: aftsConfig.env,
});
logger_1.logger.debug('AFTS generate success with env: %s', aftsConfig.env);
const resp = await (0, yuyan_common_util_1.promiseControl)(artifactPathList, async (artifact) => {
logger_1.logger.debug('AFTS now upload: %j', artifact);
const fileStream = node_fs_1.default.createReadStream(artifact.fullPath);
const [uploadResp] = await afts.upload({
name: artifact.name,
stream: fileStream,
access: 'public',
}, {});
logger_1.logger.debug('upload file: %j to AFTS result: %j', artifact, uploadResp);
return {
...uploadResp,
...artifact,
};
}, {
concurrency: 1,
});
const zstFileInfo = resp.find((file) => file.extName === '.zst');
const binFileInfo = resp.find((file) => file.extName === '.bin');
const mockFileInfo = resp.find((file) => file.extName === '.mock');
if (!zstFileInfo) {
throw new Error('cannot find .zst upload record');
}
const fileList = [
{
fileId: zstFileInfo.id,
md5: zstFileInfo.md5,
name: zstFileInfo.fullName,
},
];
if (binFileInfo) {
fileList.push({
fileId: binFileInfo.id,
md5: binFileInfo.md5,
name: binFileInfo.fullName,
});
}
if (mockFileInfo) {
fileList.push({
fileId: mockFileInfo.id,
md5: mockFileInfo.md5,
name: mockFileInfo.fullName,
});
}
return {
md5: zstFileInfo.md5,
fileId: zstFileInfo.id,
mockMd5: mockFileInfo?.md5 || '',
mockFileId: mockFileInfo?.id || '',
fileList,
};
}
}
exports.AFTSUtil = AFTSUtil;