@lcap/cli
Advanced tools
| import { CommandOptions } from './types'; | ||
| export declare function bumpCommand(root: string, opt: CommandOptions): Promise<void>; | ||
| //# sourceMappingURL=api.d.ts.map |
| {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/bump/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAc,MAAM,SAAS,CAAC;AAmCrD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,iBAgDlE"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.bumpCommand = void 0; | ||
| const promises_1 = require("fs/promises"); | ||
| const path_1 = require("path"); | ||
| const utils_1 = require("../utils"); | ||
| /** 项目仓库地址 */ | ||
| const projectId = 'vusion/lcap-ide'; | ||
| async function bumpNasl(version, opt) { | ||
| const [mainString, betaString] = version.split('-'); | ||
| const [major, minor, patch] = mainString.split('.').map((item) => (item && !Number.isNaN(Number(item))) ? Number(item) : 0); | ||
| const betaVersion = Number(betaString?.split('.')?.[1] ?? '0'); | ||
| switch (opt.type) { | ||
| case 'prerelease': { | ||
| return `${major}.${minor}.${patch}-beta.${betaVersion + 1}`; | ||
| } | ||
| case 'release': { | ||
| return `${major}.${minor}.${patch + 1}`; | ||
| } | ||
| case 'minor': { | ||
| return `${major}.${minor + 1}.0`; | ||
| } | ||
| default: { | ||
| throw new Error(`错误的升级选项:${opt.type}`); | ||
| } | ||
| } | ||
| } | ||
| async function bumpCommand(root, opt) { | ||
| const tokenData = await (0, utils_1.getSecretByOption)(root, opt); | ||
| const mainNaslVersion = JSON.parse(await (0, promises_1.readFile)((0, path_1.join)(root, 'packages/nasl/package.json'), 'utf-8')).version; | ||
| utils_1.logger.info(`主包 @lcap/nasl 当前版本号为:${mainNaslVersion}`); | ||
| utils_1.logger.info(`升级选项为:${opt.type}`); | ||
| const updateVersion = await bumpNasl(mainNaslVersion, opt); | ||
| utils_1.logger.info(`升级后版本为:${updateVersion}`); | ||
| utils_1.logger.info(`正在写入硬盘...`); | ||
| const naslPackages = await (0, promises_1.readdir)((0, path_1.join)(root, 'packages')).then((list) => list.filter((item) => item.startsWith('nasl'))); | ||
| for (const pkg of naslPackages) { | ||
| const pkgFilePath = (0, path_1.join)(root, 'packages', pkg, 'package.json'); | ||
| const pkgData = JSON.parse(await (0, promises_1.readFile)(pkgFilePath, 'utf-8')); | ||
| if (opt.exclude.includes(pkgData.name)) { | ||
| continue; | ||
| } | ||
| pkgData.version = updateVersion; | ||
| await (0, promises_1.writeFile)(pkgFilePath, JSON.stringify(pkgData, null, 2) + '\n'); | ||
| } | ||
| utils_1.logger.info(`硬盘写入完成,开始提交代码...`); | ||
| const bumpBranch = `bump/nasl-${updateVersion}`; | ||
| await (0, utils_1.runCommand)(`git checkout -b ${bumpBranch}`); | ||
| await (0, utils_1.runCommand)('git add -A'); | ||
| await (0, utils_1.runCommand)(`git commit -m \"Bump Nasl: 升级 Nasl 版本至 ${updateVersion}\"`); | ||
| await (0, utils_1.runCommand)(`git push --set-upstream origin ${bumpBranch}`); | ||
| utils_1.logger.info(`当前分支为:${bumpBranch}`); | ||
| utils_1.logger.info(`开始创建提交...`); | ||
| const gitlab = new utils_1.Gitlab(projectId, tokenData.tokenId); | ||
| const mrData = await gitlab.createMrWithBranch({ | ||
| target_branch: opt.targetBranch, | ||
| source_branch: bumpBranch, | ||
| title: `升级 Nasl 版本至:${updateVersion}`, | ||
| squash: true, | ||
| remove_source_branch: true, | ||
| labels: 'auto-bump;nasl' | ||
| }); | ||
| utils_1.logger.info(`MR 创建成功,MR 链接为:${utils_1.color.blackBright(mrData.web_url)}`); | ||
| if (opt.output) { | ||
| utils_1.logger.info(`MR 结果写入上下文...`); | ||
| await (0, utils_1.writeContext)(root, opt.output, { | ||
| mr_url: mrData.web_url, | ||
| nasl_version: updateVersion, | ||
| }); | ||
| } | ||
| } | ||
| exports.bumpCommand = bumpCommand; | ||
| //# sourceMappingURL=api.js.map |
| {"version":3,"file":"api.js","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,MAAM,EAAE;YAC/C,MAAM,EAAE,MAAM,CAAC,OAAO;YACtB,YAAY,EAAE,aAAa;SAC5B,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAhDD,kCAgDC"} |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; | ||
| //# sourceMappingURL=command.d.ts.map |
| {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/bump/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAsCrD"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const api_1 = require("./api"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('bump', '升级 Nasl 包版本', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('type', { | ||
| type: 'string', | ||
| describe: '升级版本类别', | ||
| choices: ['prerelease', 'release'], | ||
| default: 'prerelease', | ||
| }) | ||
| .option('targetBranch', { | ||
| type: 'string', | ||
| describe: '合并到哪个分支', | ||
| default: 'test', | ||
| }) | ||
| .option('exclude', { | ||
| type: 'array', | ||
| describe: '不发包的子包名称', | ||
| default: [], | ||
| }) | ||
| .option('output', { | ||
| type: 'string', | ||
| describe: '结果储存文件', | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, api_1.bumpCommand)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; | ||
| //# sourceMappingURL=command.js.map |
| {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/bump/command.ts"],"names":[],"mappings":";;;AACA,oCAAuE;AAEvE,+BAAoC;AAEpC,SAAgB,eAAe,CAAC,KAAsB;IACpD,KAAK,CAAC,OAAO,CACX,MAAM,EACN,aAAa,EACb,CAAC,KAAK,EAAE,EAAE;QACR,KAAK;aACF,OAAO,CAAC,oBAAY,CAAC;aACrB,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC;YAClC,OAAO,EAAE,YAAY;SACtB,CAAC;aACD,MAAM,CAAC,cAAc,EAAE;YACtB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,MAAM;SAChB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,UAAU;YACpB,OAAO,EAAE,EAAE;SACZ,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ;SACnB,CAAC;aACD,KAAK,CAAC,CAAC,IAAgC,EAAE,EAAE;YAC1C,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACP,CAAC,EACD,CAAC,IAA8C,EAAE,EAAE;QACjD,OAAO,IAAA,iBAAW,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;YAC3D,cAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAtCD,0CAsCC"} |
| export { registerCommand } from './command'; | ||
| export * from './api'; | ||
| export * from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bump/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); | ||
| __exportStar(require("./api"), exports); | ||
| __exportStar(require("./types"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bump/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AAExB,wCAAsB;AACtB,0CAAwB"} |
| import type { TokenData } from '../utils'; | ||
| export interface CommandOptions extends TokenData { | ||
| /** 升级版本类别 */ | ||
| type: 'prerelease' | 'release' | 'minor'; | ||
| /** 合并到哪个分支 */ | ||
| targetBranch: string; | ||
| /** 排除子包 */ | ||
| exclude: string[]; | ||
| /** 临时输出文件 */ | ||
| output: string; | ||
| } | ||
| export interface OutputData { | ||
| mr_url: string; | ||
| nasl_version: string; | ||
| } | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bump/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,aAAa;IACb,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;IACzC,cAAc;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bump/types.ts"],"names":[],"mappings":""} |
| export declare function run(): void; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAQA,wBAAgB,GAAG,SAUlB"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.run = void 0; | ||
| const yargs_1 = __importDefault(require("yargs")); | ||
| const publish_1 = require("../publish"); | ||
| const popo_1 = require("../popo"); | ||
| const trigger_1 = require("../trigger"); | ||
| const release_1 = require("../release"); | ||
| const bump_1 = require("../bump"); | ||
| function run() { | ||
| (0, publish_1.registerCommand)(yargs_1.default); | ||
| (0, popo_1.registerCommand)(yargs_1.default); | ||
| (0, trigger_1.registerCommand)(yargs_1.default); | ||
| (0, release_1.registerCommand)(yargs_1.default); | ||
| (0, bump_1.registerCommand)(yargs_1.default); | ||
| yargs_1.default | ||
| .strict() | ||
| .showHelpOnFail(false).argv; | ||
| } | ||
| exports.run = run; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wCAAuE;AACvE,kCAAiE;AACjE,wCAAuE;AACvE,wCAAuE;AACvE,kCAAiE;AAEjE,SAAgB,GAAG;IACjB,IAAA,yBAAsB,EAAC,eAAK,CAAC,CAAC;IAC9B,IAAA,sBAAmB,EAAC,eAAK,CAAC,CAAC;IAC3B,IAAA,yBAAsB,EAAC,eAAK,CAAC,CAAC;IAC9B,IAAA,yBAAsB,EAAC,eAAK,CAAC,CAAC;IAC9B,IAAA,sBAAmB,EAAC,eAAK,CAAC,CAAC;IAE3B,eAAK;SACF,MAAM,EAAE;SACR,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAChC,CAAC;AAVD,kBAUC"} |
| export * from './cli'; | ||
| export * as bump from './bump'; | ||
| export * as publish from './publish'; | ||
| export * as popo from './popo'; | ||
| export * as trigger from './trigger'; | ||
| export * as release from './release'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AAEtB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"} |
+36
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.release = exports.trigger = exports.popo = exports.publish = exports.bump = void 0; | ||
| __exportStar(require("./cli"), exports); | ||
| exports.bump = __importStar(require("./bump")); | ||
| exports.publish = __importStar(require("./publish")); | ||
| exports.popo = __importStar(require("./popo")); | ||
| exports.trigger = __importStar(require("./trigger")); | ||
| exports.release = __importStar(require("./release")); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAsB;AAEtB,+CAA+B;AAC/B,qDAAqC;AACrC,+CAA+B;AAC/B,qDAAqC;AACrC,qDAAqC"} |
| import axios from 'axios'; | ||
| import { SecretData, MessageData } from './types'; | ||
| export declare function fetchToken(token: SecretData): Promise<string>; | ||
| /** 对单人发消息 */ | ||
| export declare function postRobotP2P(token: string, body: MessageData): Promise<axios.AxiosResponse<any, any>>; | ||
| /** 群发消息 */ | ||
| export declare function postRobotTeam(token: string, body: MessageData): Promise<axios.AxiosResponse<any, any>>; | ||
| /** | ||
| * 通过邮箱反查用户名称 | ||
| */ | ||
| export declare function getPersonName(token: string, email: string): Promise<string | undefined>; | ||
| //# sourceMappingURL=api.d.ts.map |
| {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/popo/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EACL,UAAU,EAKV,WAAW,EAEZ,MAAM,SAAS,CAAC;AAEjB,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,mBAiB3C;AAED,aAAa;AACb,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,0CAalE;AAED,WAAW;AACX,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,0CAsCnE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,+BAa/D"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getPersonName = exports.postRobotTeam = exports.postRobotP2P = exports.fetchToken = void 0; | ||
| const axios_1 = __importDefault(require("axios")); | ||
| const constant_1 = require("./constant"); | ||
| const utils_1 = require("../utils"); | ||
| function fetchToken(token) { | ||
| return axios_1.default | ||
| .post(constant_1.PopoApi.GetToken, { | ||
| appId: token.id, | ||
| appSecret: token.secret, | ||
| }, { | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }) | ||
| .then(({ data }) => { | ||
| return data.data.openAccessToken; | ||
| }); | ||
| } | ||
| exports.fetchToken = fetchToken; | ||
| /** 对单人发消息 */ | ||
| async function postRobotP2P(token, body) { | ||
| const data = { | ||
| sender: body.sender, | ||
| receiver: body.receiver, | ||
| message: (0, utils_1.formatMessage)(body.message), | ||
| }; | ||
| return axios_1.default.post(constant_1.PopoApi.ToPerson, data, { | ||
| headers: { | ||
| 'Open-Access-Token': token, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
| } | ||
| exports.postRobotP2P = postRobotP2P; | ||
| /** 群发消息 */ | ||
| async function postRobotTeam(token, body) { | ||
| const data = { | ||
| sender: body.sender, | ||
| receiver: body.receiver, | ||
| message: (0, utils_1.formatMessage)(body.message), | ||
| atUids: [], | ||
| isAtAll: false, | ||
| }; | ||
| if (data.message.includes('@所有人')) { | ||
| data.isAtAll = true; | ||
| } | ||
| const emails = (data.message.match(/@[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+(\.[a-zA-Z]+)+/g) ?? []) | ||
| .map((email) => email.substring(1)); | ||
| if (emails && emails.length > 0) { | ||
| const names = await Promise.all(emails.map((email) => getPersonName(token, email))); | ||
| for (let i = 0; i < emails.length; i++) { | ||
| const email = emails[i]; | ||
| const name = names[i]; | ||
| if (email && name && typeof name === 'string') { | ||
| data.message = data.message.replace(`@${email}`, `@${name}`); | ||
| data.atUids.push(email); | ||
| } | ||
| } | ||
| } | ||
| return axios_1.default.post(constant_1.PopoApi.ToTeam, data, { | ||
| headers: { | ||
| 'Open-Access-Token': token, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
| } | ||
| exports.postRobotTeam = postRobotTeam; | ||
| /** | ||
| * 通过邮箱反查用户名称 | ||
| */ | ||
| async function getPersonName(token, email) { | ||
| return axios_1.default | ||
| .get(constant_1.PopoApi.GetPerson, { | ||
| params: { | ||
| email, | ||
| }, | ||
| headers: { | ||
| 'Open-Access-Token': token, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }) | ||
| .then(({ data }) => data.data.name) | ||
| .catch(() => void 0); | ||
| } | ||
| exports.getPersonName = getPersonName; | ||
| //# sourceMappingURL=api.js.map |
| {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/popo/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yCAAqC;AACrC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S,EAAE;QAClD,MAAM,EAAE;YACN,KAAK;SACN;QACD,OAAO,EAAE;YACP,mBAAmB,EAAE,KAAK;YAC1B,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC;SACD,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SAClC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACzB,CAAC;AAbD,sCAaC"} |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; | ||
| //# sourceMappingURL=command.d.ts.map |
| {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/popo/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAmCrD"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const sender_1 = require("./sender"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('message', '发送 POPO 消息', | ||
| // @ts-ignore | ||
| (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('kind', { | ||
| type: 'string', | ||
| describe: '消息类别', | ||
| choices: ['person', 'team'], | ||
| demandOption: true, | ||
| }) | ||
| .option('receiver', { | ||
| type: 'string', | ||
| describe: '接收消息的人或者群', | ||
| demandOption: true, | ||
| }) | ||
| .option('message', { | ||
| type: 'string', | ||
| describe: '消息文本', | ||
| demandOption: true, | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, sender_1.sendMessage)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; | ||
| //# sourceMappingURL=command.js.map |
| {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/popo/command.ts"],"names":[],"mappings":";;;AACA,oCAAuE;AACvE,qCAAuC;AAGvC,SAAgB,eAAe,CAAC,KAAsB;IACpD,KAAK,CAAC,OAAO,CACX,SAAS,EACT,YAAY;IACZ,aAAa;IACb,CAAC,KAAK,EAAE,EAAE;QACR,KAAK;aACF,OAAO,CAAC,oBAAY,CAAC;aACrB,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;YAC3B,YAAY,EAAE,IAAI;SACnB,CAAC;aACD,MAAM,CAAC,UAAU,EAAE;YAClB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,WAAW;YACrB,YAAY,EAAE,IAAI;SACnB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,MAAM;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC;aACD,KAAK,CAAC,CAAC,IAAgC,EAAE,EAAE;YAC1C,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACP,CAAC,EACD,CAAC,IAA8C,EAAE,EAAE;QACjD,OAAO,IAAA,oBAAW,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;YAC3D,cAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAnCD,0CAmCC"} |
| /** | ||
| * POPO 公共 API | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export declare const PopoApi: { | ||
| GetToken: string; | ||
| GetPerson: string; | ||
| ToTeam: string; | ||
| ToPerson: string; | ||
| }; | ||
| //# sourceMappingURL=constant.d.ts.map |
| {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/popo/constant.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PopoApi = void 0; | ||
| /** | ||
| * POPO 公共 API | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| exports.PopoApi = { | ||
| GetToken: 'https://open.popo.netease.com/open-apis/token', | ||
| GetPerson: 'https://open.popo.netease.com/open-apis/corp/v1/employee', | ||
| ToTeam: 'https://open.popo.netease.com/open-apis/robot/v1/team', | ||
| ToPerson: 'https://open.popo.netease.com/open-apis/robot/v1/p2p', | ||
| }; | ||
| //# sourceMappingURL=constant.js.map |
| {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/popo/constant.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,OAAO,GAAG;IACrB,QAAQ,EAAE,+CAA+C;IACzD,SAAS,EAAE,0DAA0D;IACrE,MAAM,EAAE,uDAAuD;IAC/D,QAAQ,EAAE,sDAAsD;CACjE,CAAC"} |
| export { registerCommand } from './command'; | ||
| export * from './api'; | ||
| export * from './sender'; | ||
| export * from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); | ||
| __exportStar(require("./api"), exports); | ||
| __exportStar(require("./sender"), exports); | ||
| __exportStar(require("./types"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/popo/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AAExB,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"} |
| import { CommandOptions } from './types'; | ||
| export declare function sendMessage(root: string, opt: CommandOptions): Promise<void>; | ||
| //# sourceMappingURL=sender.d.ts.map |
| {"version":3,"file":"sender.d.ts","sourceRoot":"","sources":["../../src/popo/sender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAc,MAAM,SAAS,CAAC;AAIrD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,iBAalE"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.sendMessage = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const api_1 = require("./api"); | ||
| async function sendMessage(root, opt) { | ||
| const secret = await (0, utils_1.getSecretByOption)(root, opt); | ||
| const token = await (0, api_1.fetchToken)(secret); | ||
| const data = { | ||
| ...opt, | ||
| sender: secret.sender, | ||
| }; | ||
| if (opt.kind === 'person') { | ||
| (0, api_1.postRobotP2P)(token, data); | ||
| } | ||
| else { | ||
| (0, api_1.postRobotTeam)(token, data); | ||
| } | ||
| } | ||
| exports.sendMessage = sendMessage; | ||
| //# sourceMappingURL=sender.js.map |
| {"version":3,"file":"sender.js","sourceRoot":"","sources":["../../src/popo/sender.ts"],"names":[],"mappings":";;;AACA,oCAA6C;AAC7C,+BAAgE;AAEzD,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,GAAmB;IACjE,MAAM,MAAM,GAAG,MAAM,IAAA,yBAAiB,EAAa,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,MAAM,IAAA,gBAAU,EAAC,MAAM,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG;QACX,GAAG,GAAG;QACN,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;IAEF,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAA,kBAAY,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,IAAA,mBAAa,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAbD,kCAaC"} |
| import type { TokenData } from '../utils'; | ||
| /** | ||
| * POPO 群消息数据 | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export interface TeamMessageData { | ||
| /** 机器人账号 */ | ||
| sender: string; | ||
| /** | ||
| * 群号 | ||
| * | ||
| * @description 机器人必须在群内 | ||
| */ | ||
| receiver: string; | ||
| /** | ||
| * 消息内容 | ||
| * | ||
| * @description 不能超过 3000 个字符 | ||
| */ | ||
| message: string; | ||
| /** | ||
| * 提醒的成员列表 | ||
| * | ||
| * @description 成员只有在群内才生效 | ||
| * @description 文本中含有被圈的人的名称才有效 | ||
| */ | ||
| atUids?: string[]; | ||
| /** | ||
| * 是否提醒所有人 | ||
| * | ||
| * @description 群消息时有效 | ||
| * @description 消息文本中必须要有`'@所有人'`才有效 | ||
| * @default false | ||
| */ | ||
| isAtAll?: boolean; | ||
| } | ||
| /** | ||
| * POPO 个人消息数据 | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export interface PersonMessageData { | ||
| /** 机器人账号 */ | ||
| sender: string; | ||
| /** 接受消息的用户邮箱 */ | ||
| receiver: string; | ||
| /** | ||
| * 消息内容 | ||
| * | ||
| * @description 不能超过 3000 个字符 | ||
| */ | ||
| message: string; | ||
| } | ||
| /** | ||
| * 授权凭证返回接口 | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export interface TokenResponseData { | ||
| openAccessToken: string; | ||
| accessExpiredAt: number; | ||
| } | ||
| export interface MessageData { | ||
| /** 机器人账号 */ | ||
| sender: string; | ||
| /** | ||
| * 接收消息方标志符 | ||
| * | ||
| * - 个人状态时,此项为个人邮箱 | ||
| * - 群状态时,此项为群号 | ||
| */ | ||
| receiver: string; | ||
| /** | ||
| * 消息文本 | ||
| */ | ||
| message: string; | ||
| } | ||
| export interface CommandOptions extends TokenData, Omit<MessageData, 'sender'> { | ||
| /** 消息类别 */ | ||
| kind: 'person' | 'team'; | ||
| } | ||
| export interface SecretData { | ||
| id: string; | ||
| secret: string; | ||
| sender: string; | ||
| } | ||
| export interface PersonDetail { | ||
| /** 邮箱账号 */ | ||
| uid: string; | ||
| /** 工号 */ | ||
| jobNumber: string; | ||
| /** 姓名 */ | ||
| name: string; | ||
| /** 花名 */ | ||
| nickname: string; | ||
| /** 分机号 */ | ||
| extendTel: string; | ||
| /** 区域名称 */ | ||
| areaName: string; | ||
| /** 办公地点 */ | ||
| locationName: string; | ||
| /** 办公楼层 */ | ||
| floorName: string; | ||
| /** 部门名称 */ | ||
| deptNameList: string[]; | ||
| } | ||
| export interface MessageTemplateData { | ||
| /** | ||
| * 项目名称 | ||
| */ | ||
| project: string; | ||
| } | ||
| export interface PopoResponse<T> { | ||
| data: T; | ||
| errcode: number; | ||
| errmsg: string; | ||
| } | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/popo/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY;IACZ,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY;IACZ,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IAC5E,WAAW;IACX,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS;IACT,IAAI,EAAE,MAAM,CAAC;IACb,SAAS;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW;IACX,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/popo/types.ts"],"names":[],"mappings":""} |
| import type { PlatformData, AssetMapping, PublishType } from './types'; | ||
| export declare const platforms: PlatformData[]; | ||
| export declare const mappings: Record<PublishType, AssetMapping[]>; | ||
| //# sourceMappingURL=constant.d.ts.map |
| {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/publish/api/constant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvE,eAAO,MAAM,SAAS,EAAE,YAAY,EAanC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,YAAY,EAAE,CAgCxD,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mappings = exports.platforms = void 0; | ||
| exports.platforms = [ | ||
| { | ||
| name: 'dev', | ||
| display: '联调平台', | ||
| bucketName: 'lowcode-static', | ||
| endpoint: 'minio-api.codewave-dev.163yun.com', | ||
| }, | ||
| { | ||
| name: 'test', | ||
| display: '测试平台', | ||
| bucketName: 'lowcode-static', | ||
| endpoint: 'minio-api.codewave-test.163yun.com', | ||
| }, | ||
| ]; | ||
| exports.mappings = { | ||
| ide: [ | ||
| { | ||
| from: 'dist-helper', | ||
| to: (version, branch = '') => branch.length > 0 | ||
| ? `packages/branchs/${branch}/@lcap/helper@${version}/dist-helper/` | ||
| : `packages/@lcap/helper@${version}/dist-helper/`, | ||
| }, | ||
| { | ||
| from: 'dist-mdd-ide', | ||
| to: (version, branch = '') => branch.length > 0 | ||
| ? `packages/branchs/${branch}/@lcap/mdd-ide@${version}/dist-mdd-ide/` | ||
| : `packages/@lcap/mdd-ide@${version}/dist-mdd-ide/`, | ||
| }, | ||
| ], | ||
| vue3: [ | ||
| { | ||
| from: 'dist/vue.global.prod.js', | ||
| to: (version, branch = '') => 'packages/vue@3/dist/vue.min.js', | ||
| }, | ||
| ], | ||
| sandbox: [ | ||
| { | ||
| from: 'www', | ||
| to: (version, branch = '') => branch.length > 0 | ||
| ? `packages/branchs/${branch}/sandbox@${version}/` | ||
| : `packages/sandbox@${version}/`, | ||
| }, | ||
| ], | ||
| }; | ||
| //# sourceMappingURL=constant.js.map |
| {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/publish/api/constant.ts"],"names":[],"mappings":";;;AAEa,QAAA,SAAS,GAAmB;IACvC;QACE,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,gBAAgB;QAC5B,QAAQ,EAAE,mCAAmC;KAC9C;IACD;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,gBAAgB;QAC5B,QAAQ,EAAE,oCAAoC;KAC/C;CACF,CAAC;AAEW,QAAA,QAAQ,GAAwC;IAC3D,GAAG,EAAE;QACH;YACE,IAAI,EAAE,aAAa;YACnB,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE,CAC3B,MAAM,CAAC,MAAM,GAAG,CAAC;gBACf,CAAC,CAAC,oBAAoB,MAAM,iBAAiB,OAAO,eAAe;gBACnE,CAAC,CAAC,yBAAyB,OAAO,eAAe;SACtD;QACD;YACE,IAAI,EAAE,cAAc;YACpB,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE,CAC3B,MAAM,CAAC,MAAM,GAAG,CAAC;gBACf,CAAC,CAAC,oBAAoB,MAAM,kBAAkB,OAAO,gBAAgB;gBACrE,CAAC,CAAC,0BAA0B,OAAO,gBAAgB;SACxD;KACF;IACD,IAAI,EAAE;QACJ;YACE,IAAI,EAAE,yBAAyB;YAC/B,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE,CAAC,gCAAgC;SAC/D;KACF;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,KAAK;YACX,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE,CAC3B,MAAM,CAAC,MAAM,GAAG,CAAC;gBACf,CAAC,CAAC,oBAAoB,MAAM,YAAY,OAAO,GAAG;gBAClD,CAAC,CAAC,oBAAoB,OAAO,GAAG;SACrC;KACF;CACF,CAAC"} |
| export * from './types'; | ||
| export * from './publish'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/publish/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./types"), exports); | ||
| __exportStar(require("./publish"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/publish/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B"} |
| import type { CommandOptions } from './types'; | ||
| export declare function publish(root: string, opt: CommandOptions): Promise<void>; | ||
| //# sourceMappingURL=publish.d.ts.map |
| {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/publish/api/publish.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,SAAS,CAAC;AA+D1D,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,iBAuG9D"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.publish = void 0; | ||
| const path_1 = __importDefault(require("path")); | ||
| const promises_1 = require("fs/promises"); | ||
| const recursive_readdir_1 = __importDefault(require("recursive-readdir")); | ||
| const client_1 = require("../client"); | ||
| const secret_1 = require("../../utils/secret"); | ||
| const project_1 = require("../../utils/project"); | ||
| const constant_1 = require("./constant"); | ||
| const log_1 = require("../../utils/log"); | ||
| const string_1 = require("../../utils/string"); | ||
| async function getOptions(root, opt) { | ||
| if (!opt.token && !opt.tokenFile) { | ||
| throw new Error(`请输入${log_1.color.red('发布密钥')}`); | ||
| } | ||
| const tokenData = await (0, secret_1.getSecretByOption)(root, opt); | ||
| const platformData = constant_1.platforms.find((item) => item.name === opt.platform); | ||
| if (!platformData) { | ||
| throw new Error(`发布平台输入错误,只能输入 ` + | ||
| `${log_1.color.red('dev')}(联调平台)或者 ` + | ||
| `${log_1.color.red('test')}(测试平台)`); | ||
| } | ||
| const version = await (0, project_1.getVersion)(root); | ||
| if (!version) { | ||
| throw new Error(`错误的版本格式,请确定在 ${log_1.color.red('package.json')} ` + | ||
| `文件的 ${log_1.color.red('version')} 字段格式正确`); | ||
| } | ||
| if (opt.mode === 'independent' && !opt.branch) { | ||
| throw new Error(`独立发布模式时,分支名称不能为空`); | ||
| } | ||
| return { | ||
| ...tokenData, | ||
| ...platformData, | ||
| version, | ||
| }; | ||
| } | ||
| function getMetaData(opt) { | ||
| const data = { | ||
| 'Access-Control-Allow-Origin': '*', | ||
| }; | ||
| if (opt.publisher) { | ||
| data.Publisher = opt.publisher; | ||
| } | ||
| if (opt.publishAt) { | ||
| data.PublishAt = opt.publishAt; | ||
| } | ||
| if (opt.branch) { | ||
| data.Branch = opt.branch; | ||
| } | ||
| return data; | ||
| } | ||
| async function publish(root, opt) { | ||
| const options = await getOptions(root, opt); | ||
| const branchName = opt.branch && opt.mode === 'independent' ? (0, string_1.formatBranch)(opt.branch) : undefined; | ||
| log_1.logger.info(`发布任务开始,资源:${log_1.color.yellow(opt.type)},平台:${log_1.color.yellow(options.display)},版本号:${log_1.color.yellow(options.version)}${branchName | ||
| ? `,分支名:${log_1.color.yellow(opt.branch)}(格式化为:"${log_1.color.yellow(branchName)}")` | ||
| : ''}`); | ||
| const client = new client_1.LcapClient({ | ||
| endPoint: options.endpoint, | ||
| bucketName: options.bucketName, | ||
| accessKey: options.access, | ||
| secretKey: options.secret, | ||
| port: 80, | ||
| useSSL: false, | ||
| }); | ||
| const mappeds = constant_1.mappings[opt.type].map(({ from, to }) => ({ | ||
| from, | ||
| to: to(options.version, branchName), | ||
| })); | ||
| log_1.logger.info('服务器连接成功,开始读取硬盘文件...'); | ||
| const dirFiles = await Promise.all(mappeds.map(async ({ from, to }) => { | ||
| const baseDir = path_1.default.join(root, from); | ||
| const baseDirStat = await (0, promises_1.stat)(baseDir).catch(() => void 0); | ||
| if (!baseDirStat) { | ||
| return []; | ||
| } | ||
| if (baseDirStat.isDirectory()) { | ||
| return (0, recursive_readdir_1.default)(baseDir) | ||
| .then((allFiles) => { | ||
| return Promise.all(allFiles.map(async (item) => ({ | ||
| from: item, | ||
| content: await (0, promises_1.readFile)(item), | ||
| to: path_1.default.join(to, path_1.default.relative(baseDir, item)), | ||
| }))); | ||
| }) | ||
| .catch(() => []); | ||
| } | ||
| else { | ||
| return [ | ||
| { | ||
| from: baseDir, | ||
| content: await (0, promises_1.readFile)(baseDir), | ||
| // 输入是文件时,输出也一定是文件 | ||
| to, | ||
| } | ||
| ]; | ||
| } | ||
| })); | ||
| const files = dirFiles.reduce((ans, item) => (ans.push(...item), ans), []); | ||
| const size = files.reduce((ans, item) => ans + item.content.byteLength, 0); | ||
| const metaData = getMetaData(opt); | ||
| log_1.logger.info(`硬盘文件读取完成,共 ${log_1.color.yellow(files.length)} 个文件,` + | ||
| `${log_1.color.yellow((size / 1024 / 1024).toFixed(2))} MB`); | ||
| log_1.logger.info(`开始删除旧文件...`); | ||
| await Promise.all(dirFiles.map(async (dir, index) => { | ||
| if (dir.length === 0) { | ||
| return; | ||
| } | ||
| const list = await client.listFiles(mappeds[index].to); | ||
| await client.deleteFiles(...list); | ||
| })); | ||
| log_1.logger.info(`开始上传文件...`); | ||
| await client.putFiles(files, metaData, (file, index) => { | ||
| log_1.spinner.text = | ||
| `正在上传 ${log_1.color.yellow(path_1.default.relative(root, file))},` + | ||
| `总进度 ${log_1.color.green(index)} / ` + | ||
| `${log_1.color.red(files.length)}...`; | ||
| if (index === 1) { | ||
| log_1.spinner.start(); | ||
| } | ||
| }); | ||
| log_1.spinner.stop(); | ||
| log_1.spinner.clear(); | ||
| log_1.logger.info(`发布任务完成!`); | ||
| } | ||
| exports.publish = publish; | ||
| //# sourceMappingURL=publish.js.map |
| {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/publish/api/publish.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0CAA6C;AAC7C,0EAAyC;AACzC,sCAAkD;AAElD,+CAAuD;AACvD,iDAAiD;AACjD,yCAAiD;AACjD,yCAAyD;AACzD,+CAAkD;AAElD,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,GAAmB;IACzD,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,MAAM,WAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,0BAAiB,EAAa,IAAI,EAAE,GAAG,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,oBAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE1E,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,gBAAgB;YACd,GAAG,WAAK,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW;YAC9B,GAAG,WAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAC/B,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAU,EAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAK,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG;YAC1C,OAAO,WAAK,CAAC,GAAG,C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CAAC;IAEF,YAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAE1B,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAClD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACvD,MAAM,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC,CAAC;IAEJ,YAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEzB,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACrD,aAAO,CAAC,IAAI;YACV,QAAQ,WAAK,CAAC,MAAM,CAAC,cAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG;gBAClD,OAAO,WAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK;gBAC9B,GAAG,WAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QAElC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,aAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,aAAO,CAAC,IAAI,EAAE,CAAC;IACf,aAAO,CAAC,KAAK,EAAE,CAAC;IAChB,YAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACzB,CAAC;AAvGD,0BAuGC"} |
| import type { TokenData } from '../../utils'; | ||
| /** | ||
| * 平台数据 | ||
| */ | ||
| export interface PlatformData { | ||
| /** | ||
| * 平台名称 | ||
| */ | ||
| name: 'dev' | 'test'; | ||
| /** | ||
| * 平台显示名称 | ||
| */ | ||
| display: string; | ||
| /** | ||
| * 平台链接 | ||
| */ | ||
| endpoint: string; | ||
| /** | ||
| * 资源桶名称 | ||
| */ | ||
| bucketName: string; | ||
| } | ||
| /** 密钥数据 */ | ||
| export interface SecretData { | ||
| access: string; | ||
| secret: string; | ||
| } | ||
| /** 资源映射 */ | ||
| export interface AssetMapping { | ||
| /** 本地文件夹 */ | ||
| from: string; | ||
| /** | ||
| * 线上文件夹 | ||
| * | ||
| * @description 线上路径需要和版本号以及分支名称拼接 | ||
| */ | ||
| to(version: string, branch?: string): string; | ||
| } | ||
| export type PublishType = 'ide' | 'vue3' | 'sandbox'; | ||
| export interface CommandOptions extends TokenData { | ||
| /** 发布平台 */ | ||
| platform: PlatformData['name']; | ||
| /** 发布资源 */ | ||
| type: PublishType; | ||
| /** 发布模式 */ | ||
| mode: 'normal' | 'independent'; | ||
| /** 发布人账号 */ | ||
| publisher?: string; | ||
| /** | ||
| * 发布时间 | ||
| * | ||
| * @description ISO 8601 format | ||
| */ | ||
| publishAt?: string; | ||
| /** 当前分支名称 */ | ||
| branch?: string; | ||
| } | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/publish/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,WAAW;AACX,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,WAAW;AACX,MAAM,WAAW,YAAY;IAC3B,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9C;AAED,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,WAAW;IACX,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/B,WAAW;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW;IACX,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;IAC/B,YAAY;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/publish/api/types.ts"],"names":[],"mappings":""} |
| /// <reference types="node" /> | ||
| import { ClientOptions } from 'minio'; | ||
| /** 资源数据 */ | ||
| export interface AssetData { | ||
| /** 本地文件夹 */ | ||
| from: string; | ||
| /** 线上文件夹 */ | ||
| to: string; | ||
| /** 资源数据 */ | ||
| content: Buffer; | ||
| } | ||
| export type LcapClientOptions = ClientOptions & { | ||
| bucketName: string; | ||
| }; | ||
| /** | ||
| * 操作进度 | ||
| * | ||
| * @description 当前操作的进度 | ||
| * @param {string} file 当前文件 | ||
| * @param {number} fileIndex 当前文件是输入文件列表的第几个 | ||
| * @param {number} [progress] 当前文件的进度 | ||
| */ | ||
| export type FileProgress = (file: string, fileIndex: number) => void; | ||
| export declare class LcapClient { | ||
| /** 桶名称 */ | ||
| private bucketName; | ||
| /** 原始客户端 */ | ||
| private client; | ||
| constructor({ bucketName, ...restOpt }: LcapClientOptions); | ||
| listFiles(basePath: string): Promise<string[]>; | ||
| readFile(fileName: string): Promise<Buffer>; | ||
| putFiles(files: AssetData[], metaData?: Record<string, string>, progress?: FileProgress): Promise<void>; | ||
| deleteFiles(...fileNames: string[]): Promise<void>; | ||
| } | ||
| //# sourceMappingURL=client.d.ts.map |
| {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/publish/client/client.ts"],"names":[],"mappings":";AACA,OAAO,EAAU,aAAa,EAAE,MAAM,OAAO,CAAC;AAG9C,WAAW;AACX,MAAM,WAAW,SAAS;IACxB,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,WAAW;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;AAErE,qBAAa,UAAU;IACrB,UAAU;IACV,OAAO,CAAC,UAAU,CAAS;IAE3B,YAAY;IACZ,OAAO,CAAC,MAAM,CAAS;gBAEX,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB;IAKzD,SAAS,CAAC,QAAQ,EAAE,MAAM;IAY1B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAkBnB,QAAQ,CACZ,KAAK,EAAE,SAAS,EAAE,EAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,QAAQ,CAAC,EAAE,YAAY;IAezB,WAAW,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE;CAGnC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.LcapClient = void 0; | ||
| const mime_1 = require("mime"); | ||
| const minio_1 = require("minio"); | ||
| const utils_1 = require("../../utils"); | ||
| class LcapClient { | ||
| constructor({ bucketName, ...restOpt }) { | ||
| this.client = new minio_1.Client(restOpt); | ||
| this.bucketName = bucketName; | ||
| } | ||
| listFiles(basePath) { | ||
| const files = []; | ||
| return new Promise((resolve, reject) => { | ||
| this.client | ||
| .listObjects(this.bucketName, basePath, true) | ||
| .on('data', (item) => item.name && files.push(item.name)) | ||
| .on('end', () => resolve(files)) | ||
| .on('error', (err) => reject(err)); | ||
| }); | ||
| } | ||
| readFile(fileName) { | ||
| return new Promise((resolve, reject) => { | ||
| this.client.getObject(this.bucketName, fileName, (error, read) => { | ||
| if (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| let buf = new Uint8Array([]); | ||
| read | ||
| .on('data', (chunk) => buf = (0, utils_1.mergeUint8Array)(buf, chunk)) | ||
| .on('end', () => resolve(Buffer.from(buf))) | ||
| .on('error', (err) => reject(err)); | ||
| }); | ||
| }); | ||
| } | ||
| async putFiles(files, metaData, progress) { | ||
| // 这里需要等待日志打印 | ||
| await (0, utils_1.delay)(100); | ||
| for (let i = 0; i < files.length; i++) { | ||
| const { from, to, content } = files[i]; | ||
| progress?.(from, i + 1); | ||
| await this.client.putObject(this.bucketName, to, content, { | ||
| 'Content-Type': (0, mime_1.getType)(from), | ||
| ...metaData, | ||
| }); | ||
| } | ||
| } | ||
| deleteFiles(...fileNames) { | ||
| return this.client.removeObjects(this.bucketName, fileNames); | ||
| } | ||
| } | ||
| exports.LcapClient = LcapClient; | ||
| //# sourceMappingURL=client.js.map |
| {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/publish/client/client.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iCAA8C;AAC9C,uCAAqD;AA0BrD,MAAa,UAAU;IAOrB,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,EAAqB;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,cAAM,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,SAA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AC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,KAAkB,EAClB,QAAiC,EACjC,QAAuB;QAEvB,aAAa;QACb,MAAM,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;QAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE;gBACxD,cAAc,EAAE,IAAA,cAAO,EAAC,IAAI,CAAC;gBAC7B,GAAG,QAAQ;aACZ,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,WAAW,CAAC,GAAG,SAAmB;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF;AA/DD,gCA+DC"} |
| export * from './client'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/publish/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./client"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/publish/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"} |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; | ||
| //# sourceMappingURL=command.d.ts.map |
| {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/publish/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAkDrD"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const publish_1 = require("./api/publish"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('publish', '发布前端资源', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('platform', { | ||
| type: 'string', | ||
| describe: '发布平台', | ||
| choices: ['dev', 'test'], | ||
| default: 'dev', | ||
| }) | ||
| .option('type', { | ||
| type: 'string', | ||
| describe: '发布资源类型', | ||
| choices: ['ide', 'vue3', 'sandbox'], | ||
| default: 'ide', | ||
| }) | ||
| .option('mode', { | ||
| type: 'string', | ||
| describe: '发布模式,独立发布模式时将会按照分支名称独立发布', | ||
| choices: ['normal', 'independent'], | ||
| default: 'normal', | ||
| }) | ||
| .option('publisher', { | ||
| alias: 'p', | ||
| type: 'string', | ||
| describe: '发布人账号,它将会附加到资源的 Headers 中', | ||
| }) | ||
| .option('branch', { | ||
| type: 'string', | ||
| describe: '当前发布分支名称,它将会附加到资源的 Headers 中', | ||
| }) | ||
| .option('publishAt', { | ||
| alias: 't', | ||
| type: 'string', | ||
| describe: '发布时间,它将会附加到资源的 Headers 中', | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, publish_1.publish)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; | ||
| //# sourceMappingURL=command.js.map |
| {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/publish/command.ts"],"names":[],"mappings":";;;AACA,oCAA4D;AAC5D,2CAAwC;AAGxC,SAAgB,eAAe,CAAC,KAAsB;IACpD,KAAK,CAAC,OAAO,CACX,SAAS,EACT,QAAQ,EACR,CAAC,KAAK,EAAE,EAAE;QACR,KAAK;aACF,OAAO,CAAC,oBAAY,CAAC;aACrB,MAAM,CAAC,UAAU,EAAE;YAClB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;YACxB,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC;YACnC,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0BAA0B;YACpC,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;YAClC,OAAO,EAAE,QAAQ;SAClB,CAAC;aACD,MAAM,CAAC,WAAW,EAAE;YACnB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,2BAA2B;SACtC,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,8BAA8B;SACzC,CAAC;aACD,MAAM,CAAC,WAAW,EAAE;YACnB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0BAA0B;SACrC,CAAC;aACD,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,OAAO,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACP,CAAC,EACD,CAAC,IAA8C,EAAE,EAAE;QACjD,OAAO,IAAA,iBAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;YACvD,cAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAlDD,0CAkDC"} |
| export { registerCommand } from './command'; | ||
| export * from './api'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/publish/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,cAAc,OAAO,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); | ||
| __exportStar(require("./api"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/publish/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,wCAAsB"} |
| import { CommandOptions } from './types'; | ||
| export declare function release(root: string, opt: CommandOptions): Promise<void>; | ||
| //# sourceMappingURL=api.d.ts.map |
| {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/release/api.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAc,MAAM,SAAS,CAAC;AAsFrD,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,iBAI9D"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.release = void 0; | ||
| const path_1 = __importDefault(require("path")); | ||
| const recursive_readdir_1 = __importDefault(require("recursive-readdir")); | ||
| const promises_1 = require("fs/promises"); | ||
| const gitlab_1 = require("../utils/gitlab"); | ||
| const utils_1 = require("../utils"); | ||
| const constant_1 = require("./constant"); | ||
| async function autoMr(root, gitlab, data) { | ||
| const version = await (0, utils_1.getVersion)(root); | ||
| utils_1.logger.info(`当前物料 ${utils_1.color.yellow(data.kind.toUpperCase())},版本 ${utils_1.color.yellow(version)}`); | ||
| const basePathInRemote = constant_1.AssetPath.ide(version); | ||
| utils_1.logger.info(`检索远程仓库代码...`); | ||
| const filesInRemote = await gitlab.listFiles(basePathInRemote, constant_1.AssetRef); | ||
| utils_1.logger.info(`读取本地文件...`); | ||
| const filesInDisk = await (0, recursive_readdir_1.default)(data.distDir); | ||
| const filesData = await Promise.all((filesInDisk).map(async (file) => { | ||
| const diskPath = path_1.default.join(root, file); | ||
| const remotePath = path_1.default.join(basePathInRemote, path_1.default.relative(data.distDir, file)); | ||
| const fileBuffer = await (0, promises_1.readFile)(diskPath); | ||
| const size = fileBuffer.byteLength; | ||
| const content = fileBuffer.toString('base64'); | ||
| return { | ||
| diskPath, | ||
| remotePath, | ||
| size, | ||
| content, | ||
| }; | ||
| })); | ||
| if (filesData.length === 0) { | ||
| utils_1.logger.info(`未发现本地数据,进程退出。`); | ||
| if (data.output) { | ||
| utils_1.logger.info(`MR 结果写入上下文...`); | ||
| await (0, utils_1.writeContext)(root, data.output, { mr_url: 'NONE' }); | ||
| } | ||
| return; | ||
| } | ||
| utils_1.logger.info(`正在准备 Diff 数据...`); | ||
| const filesDiff = await gitlab.getFilesDiff(filesInRemote, filesData); | ||
| utils_1.logger.info(`开始创建分支...`); | ||
| const newBranchName = `auto-release/${data.kind}/${version}/${Date.now()}`; | ||
| const branchData = await gitlab.createBranch({ | ||
| branch: newBranchName, | ||
| ref: constant_1.AssetRef, | ||
| }); | ||
| utils_1.logger.info(`分支创建完成,新分支名为 ${utils_1.color.yellow(newBranchName)},分支链接为:${branchData.web_url}`); | ||
| utils_1.logger.info(`开始提交代码...`); | ||
| const commitData = await gitlab.createCommitWithFiles({ | ||
| commit_message: `auto-release: 🔧 自动提交 ${version} 版本 ${data.kind.toUpperCase()} 物料`, | ||
| branch: newBranchName, | ||
| actions: filesDiff, | ||
| author_name: data.authorName, | ||
| author_email: data.authorEmail, | ||
| force: false, | ||
| }); | ||
| utils_1.logger.info(`代码提交成功,Commit 链接为:${utils_1.color.blackBright(commitData.web_url)}`); | ||
| utils_1.logger.info(`开始创建 MR...`); | ||
| const params = { | ||
| version, | ||
| time: Date.now(), | ||
| kind: data.kind, | ||
| }; | ||
| const mergeRequestData = await gitlab.createMrWithBranch({ | ||
| target_branch: constant_1.AssetRef, | ||
| source_branch: newBranchName, | ||
| title: (0, utils_1.formatMessageByParams)(data.mrTitle, params), | ||
| description: (0, utils_1.formatMessageByParams)(data.mrMessage, params), | ||
| squash: true, | ||
| remove_source_branch: true, | ||
| labels: 'auto-release' | ||
| }); | ||
| utils_1.logger.info(`MR 创建成功,MR 链接为:${utils_1.color.blackBright(mergeRequestData.web_url)}`); | ||
| if (data.output) { | ||
| utils_1.logger.info(`MR 结果写入上下文...`); | ||
| await (0, utils_1.writeContext)(root, data.output, { | ||
| mr_url: mergeRequestData.web_url, | ||
| }); | ||
| } | ||
| utils_1.logger.info(`代码自动合并结束!`); | ||
| } | ||
| async function release(root, opt) { | ||
| const tokenData = await (0, utils_1.getSecretByOption)(root, opt); | ||
| const gitlab = new gitlab_1.Gitlab(constant_1.AssetsReleaseId, tokenData.tokenId); | ||
| return autoMr(root, gitlab, opt); | ||
| } | ||
| exports.release = release; | ||
| //# sourceMappingURL=api.js.map |
| {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/release/api.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0EAAyC;AACzC,0CAAuC;AACvC,4CAAwD;AAExD,oCAA8H;AAC9H,yCAAkE;AAElE,KAAK,UAAU,MAAM,CAAC,IAAY,EAAE,MAAc,EAAE,IAAgB;IAClE,MAAM,OAAO,GAAG,MAAM,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;IACvC,cAAM,CAAC,IAAI,CAAC,QAAQ,aAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,aAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACzF,MAAM,gBAAgB,GAAG,oBAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChD,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AQ;QACvB,aAAa,EAAE,aAAa;QAC5B,KAAK,EAAE,IAAA,6BAAqB,EAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;QAClD,WAAW,EAAE,IAAA,6BAAqB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;QAC1D,MAAM,EAAE,IAAI;QACZ,oBAAoB,EAAE,IAAI;QAC1B,MAAM,EAAE,cAAc;KACvB,CAAC,CAAC;IACH,cAAM,CAAC,IAAI,CAAC,kBAAkB,aAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAE7E,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,cAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7B,MAAM,IAAA,oBAAY,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;YACpC,MAAM,EAAE,gBAAgB,CAAC,OAAO;SACjC,CAAC,CAAC;IACL,CAAC;IAED,cAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3B,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,GAAmB;IAC7D,MAAM,SAAS,GAAG,MAAM,IAAA,yBAAiB,EAAkB,IAAI,EAAE,GAAG,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,0BAAe,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAJD,0BAIC"} |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; | ||
| //# sourceMappingURL=command.d.ts.map |
| {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/release/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAmDrD"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const api_1 = require("./api"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('release', '前端物料发布', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('kind', { | ||
| type: 'string', | ||
| describe: '发布物料种类', | ||
| choices: ['ide'], | ||
| default: 'ide', | ||
| }) | ||
| .option('distDir', { | ||
| type: 'string', | ||
| describe: '物料文件目录', | ||
| demandOption: true, | ||
| }) | ||
| .option('mrTitle', { | ||
| type: 'string', | ||
| describe: 'MR 标题', | ||
| default: 'auto-release/[kind]-[version]-[time]', | ||
| }) | ||
| .option('mrMessage', { | ||
| type: 'string', | ||
| describe: 'MR 描述', | ||
| default: '', | ||
| }) | ||
| .option('authorEmail', { | ||
| type: 'string', | ||
| describe: '作者邮箱', | ||
| }) | ||
| .option('authorName', { | ||
| type: 'string', | ||
| describe: '作者姓名', | ||
| }) | ||
| .option('output', { | ||
| type: 'string', | ||
| describe: '结果储存文件', | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, api_1.release)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; | ||
| //# sourceMappingURL=command.js.map |
| {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/release/command.ts"],"names":[],"mappings":";;;AACA,oCAA4D;AAC5D,+BAAgC;AAGhC,SAAgB,eAAe,CAAC,KAAsB;IACpD,KAAK,CAAC,OAAO,CACX,SAAS,EACT,QAAQ,EACR,CAAC,KAAK,EAAE,EAAE;QACR,KAAK;aACF,OAAO,CAAC,oBAAY,CAAC;aACrB,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YAC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= "vusion/lcap-assets"; | ||
| /** | ||
| * 合入分支 | ||
| */ | ||
| export declare const AssetRef = "master"; | ||
| /** | ||
| * 物料出口 | ||
| */ | ||
| export declare const AssetPath: Record<ReleaseKind, (version: string) => string>; | ||
| //# sourceMappingURL=constant.d.ts.map |
| {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/release/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,aAAa;AACb,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,WAAW,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAEtE,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AssetPath = exports.AssetRef = exports.AssetsReleaseId = void 0; | ||
| /** 物料仓库编号 */ | ||
| exports.AssetsReleaseId = 'vusion/lcap-assets'; | ||
| /** | ||
| * 合入分支 | ||
| */ | ||
| exports.AssetRef = 'master'; | ||
| /** | ||
| * 物料出口 | ||
| */ | ||
| exports.AssetPath = { | ||
| ide: (version) => `data/packages/@lcap/mdd-ide@${version}/dist-mdd-ide`, | ||
| }; | ||
| //# sourceMappingURL=constant.js.map |
| {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/release/constant.ts"],"names":[],"mappings":";;;AAEA,aAAa;AACA,QAAA,eAAe,GAAG,oBAAoB,CAAC;AAEpD;;GAEG;AACU,QAAA,QAAQ,GAAG,QAAQ,CAAC;AAEjC;;GAEG;AACU,QAAA,SAAS,GAAqD;IACzE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,+BAA+B,OAAO,eAAe;CACxE,CAAC"} |
| export * from './command'; | ||
| export * from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/release/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./command"), exports); | ||
| __exportStar(require("./types"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/release/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB"} |
| import type { TokenData } from '../utils'; | ||
| /** 物料种类 */ | ||
| export type ReleaseKind = 'ide'; | ||
| /** | ||
| * 自动创建合并请求 | ||
| */ | ||
| export interface AutoMrData { | ||
| /** | ||
| * 发布物料种类 | ||
| */ | ||
| kind: ReleaseKind; | ||
| /** | ||
| * 提交文件目录 | ||
| * | ||
| * @description 文件夹目录 | ||
| */ | ||
| distDir: string; | ||
| /** | ||
| * MR 标题 | ||
| * | ||
| * @description 允许使用的参数:[time]、[version] | ||
| */ | ||
| mrTitle: string; | ||
| /** | ||
| * MR 描述 | ||
| * | ||
| * @description 允许使用的参数:[time]、[version] | ||
| */ | ||
| mrMessage: string; | ||
| /** | ||
| * 作者邮箱 | ||
| */ | ||
| authorEmail: string; | ||
| /** | ||
| * 作者姓名 | ||
| */ | ||
| authorName: string; | ||
| /** | ||
| * 临时文件 | ||
| */ | ||
| output: string; | ||
| } | ||
| export type CommandOptions = TokenData & AutoMrData; | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/release/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,WAAW;AACX,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/release/types.ts"],"names":[],"mappings":""} |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; | ||
| //# sourceMappingURL=command.d.ts.map |
| {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/trigger/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QA6DrD"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const trigger_1 = require("./trigger"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('trigger', '前端事件触发器', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('platform', { | ||
| type: 'string', | ||
| describe: '平台数据', | ||
| choices: ['dev', 'test'], | ||
| default: 'dev', | ||
| }) | ||
| .option('kind', { | ||
| type: 'string', | ||
| describe: '事件类型', | ||
| choices: ['merge_request', 'push', 'publish'], | ||
| }) | ||
| .option('id', { | ||
| type: 'string', | ||
| describe: 'MR 编号', | ||
| }) | ||
| .option('userEmail', { | ||
| type: 'string', | ||
| describe: '用户邮箱', | ||
| }) | ||
| .option('lastCommitSha', { | ||
| type: 'string', | ||
| describe: '最后一次提交的 HASH', | ||
| }) | ||
| .option('branch', { | ||
| type: 'string', | ||
| describe: '分支名称', | ||
| }) | ||
| .option('targetBranch', { | ||
| type: 'string', | ||
| describe: '合并目标分支名称', | ||
| }) | ||
| .option('output', { | ||
| type: 'string', | ||
| describe: '输出数据保存文件', | ||
| }) | ||
| .option('clear', { | ||
| type: 'boolean', | ||
| describe: '清除所有缓存', | ||
| }) | ||
| .check((argv) => { | ||
| if (argv.clear) { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| } | ||
| else { | ||
| return (0, utils_1.tokenCheck)(argv) && (0, trigger_1.check)(argv); | ||
| } | ||
| }); | ||
| }, (argv) => { | ||
| return (0, trigger_1.trigger)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; | ||
| //# sourceMappingURL=command.js.map |
| {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/trigger/command.ts"],"names":[],"mappings":";;;AACA,oCAA4D;AAC5D,uCAA2C;AAG3C,SAAgB,eAAe,CAAC,KAAsB;IACpD,KAAK,CAAC,OAAO,CACX,SAAS,EACT,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;QACR,KAAK;aACF,OAAO,CAAC,o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AAC;IACP,CAAC,EACD,CAAC,IAA8C,EAAE,EAAE;QACjD,OAAO,IAAA,iBAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;YACvD,cAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AA7DD,0CA6DC"} |
| export { registerCommand } from './command'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trigger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/trigger/index.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA"} |
| import type { BaseData, PipelineStore } from './types'; | ||
| export declare class Store { | ||
| /** 缓存文件链接 */ | ||
| static URL: string; | ||
| private readonly root; | ||
| private _client?; | ||
| data: PipelineStore; | ||
| constructor(root: string); | ||
| read(opt: BaseData): Promise<PipelineStore>; | ||
| update(): Promise<void>; | ||
| clear(): Promise<void>; | ||
| } | ||
| //# sourceMappingURL=store.d.ts.map |
| {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/trigger/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAqBvD,qBAAa,KAAK;IAChB,aAAa;IACb,MAAM,CAAC,GAAG,SAA+E;IAEzF,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,IAAI,EAAE,aAAa,CAAmB;gBAE1B,IAAI,EAAE,MAAM;IAIlB,IAAI,CAAC,GAAG,EAAE,QAAQ;IA2BlB,MAAM;IAcZ,KAAK;CAQN"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Store = void 0; | ||
| const client_1 = require("../publish/client"); | ||
| const utils_1 = require("../utils"); | ||
| const constant_1 = require("../publish/api/constant"); | ||
| const initData = { | ||
| dev: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| test: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| }; | ||
| /** 虚拟文件路径 */ | ||
| const fileViPath = 'packages/store.json'; | ||
| /** 测试平台数据 */ | ||
| const testPlatform = constant_1.platforms.find((item) => item.name === 'test'); | ||
| class Store { | ||
| /** 缓存文件链接 */ | ||
| static { this.URL = `https://${testPlatform.endpoint}/${testPlatform.bucketName}/${fileViPath}`; } | ||
| constructor(root) { | ||
| this.data = { ...initData }; | ||
| this.root = root; | ||
| } | ||
| async read(opt) { | ||
| const token = await (0, utils_1.getSecretByOption)(this.root, opt); | ||
| const client = new client_1.LcapClient({ | ||
| bucketName: testPlatform.bucketName, | ||
| endPoint: testPlatform.endpoint, | ||
| accessKey: token.access, | ||
| secretKey: token.secret, | ||
| }); | ||
| const fileInStore = await client.readFile(fileViPath).catch(() => void 0); | ||
| const data = fileInStore ? JSON.parse(fileInStore.toString('utf-8')) : { | ||
| dev: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| test: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| }; | ||
| this.data = data; | ||
| this._client = client; | ||
| return this.data; | ||
| } | ||
| async update() { | ||
| if (!this._client) { | ||
| throw new Error('请先初始化 client'); | ||
| } | ||
| return this._client.putFiles([ | ||
| { | ||
| from: fileViPath, | ||
| to: fileViPath, | ||
| content: Buffer.from(JSON.stringify(this.data)), | ||
| } | ||
| ]); | ||
| } | ||
| clear() { | ||
| if (!this._client) { | ||
| throw new Error('请先初始化 client'); | ||
| } | ||
| this.data = { ...initData }; | ||
| return this.update(); | ||
| } | ||
| } | ||
| exports.Store = Store; | ||
| //# sourceMappingURL=store.js.map |
| {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/trigger/store.ts"],"names":[],"mappings":";;;AAAA,8CAA+C;AAE/C,oCAA6C;AAE7C,sDAAoD;AAEpD,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE;QACH,EAAE,EAAE,EAAE;QACN,WAAW,EAAE,EAAE;KAChB;IACD,IAAI,EAAE;QACJ,EAAE,EAAE,EAAE;QACN,WAAW,EAAE,EAAE;KAChB;CACF,CAAC;AAEF,aAAa;AACb,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,aAAa;AACb,MAAM,YAAY,GAAG,oBAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAE,CAAC;AAErE,MAAa,KAAK;IAChB,aAAa;aACN,QAAG,GAAG,WAAW,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,UAAU,IAAI,UAAU,EAAE,AAA9E,CAA+E;IAOzF,YAAY,IAAY;QAFxB,SAAI,GAAkB,EAAE,GAAG,QAAQ,EAAE,CAAC;QAGpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAa;QACtB,MAAM,KAAK,GAAG,MAAM,IAAA,yBAAiB,EAAa,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,IAAI,mBAAU,CAAC;YAC5B,UAAU,EAAE,YAAY,CAAC,UAAU;YACnC,QAAQ,EAAE,YAAY,CAAC,QAAQ;YAC/B,SAAS,EAAE,KAAK,CAAC,M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type { CommandOptions } from './types'; | ||
| export declare function check(opt: CommandOptions): boolean; | ||
| export declare function trigger(root: string, opt: CommandOptions): Promise<void>; | ||
| //# sourceMappingURL=trigger.d.ts.map |
| {"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqD,MAAM,SAAS,CAAC;AAIjG,wBAAgB,KAAK,CAAC,GAAG,EAAE,cAAc,WAsBxC;AA2JD,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,iBAU9D"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.trigger = exports.check = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const store_1 = require("./store"); | ||
| function check(opt) { | ||
| const shouldFillProps = []; | ||
| if (opt.kind === 'merge_request') { | ||
| shouldFillProps.push('id', 'userEmail', 'lastCommitSha', 'branch', 'targetBranch'); | ||
| } | ||
| else if (opt.kind === 'publish') { | ||
| shouldFillProps.push('branch', 'lastCommitSha'); | ||
| } | ||
| else if (opt.kind === 'push') { | ||
| shouldFillProps.push('branch', 'lastCommitSha'); | ||
| } | ||
| else { | ||
| throw new Error(`未知的触发事件: ${opt.kind}`); | ||
| } | ||
| const notFilledProps = shouldFillProps.filter((key) => { | ||
| return !(key in opt); | ||
| }); | ||
| if (notFilledProps.length > 0) { | ||
| throw new Error(`事件为 ${opt.kind},缺少下列必填项: ${notFilledProps.join(', ')}`); | ||
| } | ||
| return true; | ||
| } | ||
| exports.check = check; | ||
| /** | ||
| * MR 事件 | ||
| * | ||
| * @description 只记录数据,无输出 | ||
| */ | ||
| async function triggerMergeRequest(root, opt) { | ||
| const mrData = { | ||
| id: opt.id, | ||
| userEmail: opt.userEmail, | ||
| lastCommitSha: opt.lastCommitSha, | ||
| branch: opt.branch, | ||
| targetBranch: opt.targetBranch, | ||
| }; | ||
| utils_1.logger.info(`此次记录数据为: ${JSON.stringify(mrData, null, 2)}`); | ||
| const store = new store_1.Store(root); | ||
| const data = await store.read(opt); | ||
| const platformData = data[opt.platform]; | ||
| if (platformData.mr.some((item) => item.id === mrData.id)) { | ||
| utils_1.logger.info(`有重复数据,退出流程,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| return; | ||
| } | ||
| utils_1.logger.info('没有重复数据,添加数据'); | ||
| platformData.mr.push(mrData); | ||
| await store.update(); | ||
| utils_1.logger.info(`数据更新完成,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| /** | ||
| * 发布事件 | ||
| * | ||
| * @description 在相同版本号、分支、平台相同的情况下,拉出新旧 commit 之间的所有提交人,并更新发布记录 | ||
| * @return {Promise<string>} 记录中所有人的邮箱,用逗号分隔 | ||
| */ | ||
| async function triggerPublish(root, opt) { | ||
| const store = new store_1.Store(root); | ||
| const data = await store.read(opt); | ||
| const platformData = data[opt.platform].lastPublish ?? []; | ||
| const version = await (0, utils_1.getVersion)(root); | ||
| const lastPublish = platformData.find((item) => item.versionName === version); | ||
| let gitLog = ''; | ||
| let message = ''; | ||
| if (lastPublish) { | ||
| utils_1.logger.info(`发布在 ${opt.branch} 分支的 ${version} 版本上次发布的提交是 ${lastPublish.lastCommitSha},本次提交是 ${opt.lastCommitSha}`); | ||
| gitLog = await (0, utils_1.runCommand)(`git log --pretty=format:%ae ${lastPublish.lastCommitSha}...${opt.lastCommitSha} | sort | uniq`) | ||
| .catch((e) => { | ||
| utils_1.logger.warn('未找到提交人,原始错误信息:', e.toString()); | ||
| return ''; | ||
| }); | ||
| lastPublish.lastCommitSha = opt.lastCommitSha; | ||
| lastPublish.branch = opt.branch; | ||
| } | ||
| else { | ||
| utils_1.logger.info(`首次发布在 ${opt.branch} 分支的 ${version} 版本`); | ||
| platformData.push({ | ||
| branch: opt.branch, | ||
| versionName: version, | ||
| lastCommitSha: opt.lastCommitSha, | ||
| }); | ||
| if (!data[opt.platform].lastPublish) { | ||
| data[opt.platform].lastPublish = platformData; | ||
| } | ||
| gitLog = await (0, utils_1.runCommand)(`git show -s --format='%ae' ${opt.lastCommitSha}`) | ||
| .catch((e) => { | ||
| utils_1.logger.warn('未找到提交人,原始错误信息:', e.toString()); | ||
| return ''; | ||
| }); | ||
| } | ||
| const emailArray = gitLog | ||
| .trim() | ||
| .split('\n') | ||
| .map((item) => item.trim()) | ||
| .filter((item) => item.length > 0) | ||
| .map((item) => `@${item}`); | ||
| const emails = Array.from(new Set(emailArray)); | ||
| if (emails.length === 0) { | ||
| message = `@所有人 PUSH 代码自动更新 ${version} 版本IDE\n🧩分支: ${opt.branch}`; | ||
| } | ||
| else { | ||
| message = `@所有人 PUSH 代码自动更新 ${version} 版本IDE\n🧩分支: ${opt.branch}\n🔧此次发布包含下列同事的提交: ${emails.join(',')}`; | ||
| } | ||
| await (0, utils_1.writeContext)(root, opt.output, { message }); | ||
| await store.update(); | ||
| utils_1.logger.info(`数据更新完成,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| /** | ||
| * 推送事件 | ||
| * | ||
| * @description 在推送分支比较当前所有 MR 记录下的数据,若是其内部目标分支为当前,并且其 commit 已经被当前分支包含,则表示此分支已经被合并 | ||
| * @description 若是 MR 记录已经被合并,则此记录会被删除 | ||
| * @return {Promise<[string, string, string]>} [MR 的编号, 被合并的分支名称, 提交分人的邮箱] | ||
| */ | ||
| async function triggerPush(root, opt) { | ||
| const store = new store_1.Store(root); | ||
| const data = await store.read(opt); | ||
| const platformData = data[opt.platform].mr ?? []; | ||
| if (platformData.length === 0) { | ||
| utils_1.logger.info('没有 MR 数据记录,退出流程'); | ||
| return; | ||
| } | ||
| let deleteIndex = -1; | ||
| for (let i = 0; i < platformData.length; i++) { | ||
| const data = platformData[i]; | ||
| const containBranch = await (0, utils_1.runCommand)(`git branch --contains ${data.lastCommitSha} ${opt.branch}`); | ||
| const isContainCommit = containBranch.trim() === opt.branch; | ||
| if (isContainCommit) { | ||
| utils_1.logger.info(`下述请求被包含在当前 PUSH 中: ${JSON.stringify(data, null, 2)}`); | ||
| deleteIndex = i; | ||
| break; | ||
| } | ||
| } | ||
| if (deleteIndex === -1) { | ||
| utils_1.logger.info('数据库中的 MR 请求均并未被包含在此次 PUSH 中,退出流程'); | ||
| return; | ||
| } | ||
| const deleteMrData = platformData[deleteIndex]; | ||
| platformData.splice(deleteIndex, 1); | ||
| await store.update(); | ||
| await (0, utils_1.writeContext)(root, opt.output, { | ||
| mr_id: deleteMrData.id, | ||
| mr_user: deleteMrData.userEmail, | ||
| source_branch: deleteMrData.branch, | ||
| target_branch: deleteMrData.targetBranch, | ||
| }); | ||
| utils_1.logger.info(`数据更新完成,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| /** 清空缓存 */ | ||
| async function clearTrigger(root, opt) { | ||
| const store = new store_1.Store(root); | ||
| await store.read(opt); | ||
| await store.clear(); | ||
| utils_1.logger.info(`清除缓存,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| async function trigger(root, opt) { | ||
| if (opt.clear) { | ||
| return clearTrigger(root, opt); | ||
| } | ||
| else if (opt.kind === 'merge_request') { | ||
| return triggerMergeRequest(root, opt); | ||
| } | ||
| else if (opt.kind === 'publish') { | ||
| return triggerPublish(root, opt); | ||
| } | ||
| else { | ||
| return triggerPush(root, opt); | ||
| } | ||
| } | ||
| exports.trigger = trigger; | ||
| //# sourceMappingURL=trigger.js.map |
| {"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../src/trigger/trigger.ts"],"names":[],"mappings":";;;AACA,oCAAwE;AACxE,mCAAgC;AAEhC,SAAgB,KAAK,CAAC,GAAmB;IACvC,MAAM,eAAe,GAAa,EAAE,CAAC;IAErC,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACjC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IACrF,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,KA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mB;IAC3D,MAAM,KAAK,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,cAAM,CAAC,IAAI,CAAC,mBAAmB,aAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAC9C,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,GAAmB;IAC7D,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACxC,OAAO,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAVD,0BAUC"} |
| import type { TokenData } from '../utils/secret'; | ||
| export type Platform = 'dev' | 'test'; | ||
| export interface BaseData extends TokenData { | ||
| /** 当前平台 */ | ||
| platform: Platform; | ||
| /** | ||
| * 触发事件类别 | ||
| */ | ||
| kind: string; | ||
| /** 临时文件 */ | ||
| output: string; | ||
| /** 清除缓存 */ | ||
| clear?: boolean; | ||
| } | ||
| export interface MergeRequestData { | ||
| /** MR 编号 */ | ||
| id: string; | ||
| /** 用户邮箱 */ | ||
| userEmail: string; | ||
| /** 最后一次提交的 HASH */ | ||
| lastCommitSha: string; | ||
| /** 分支名称 */ | ||
| branch: string; | ||
| /** 合并目标分支名称 */ | ||
| targetBranch: string; | ||
| } | ||
| export interface PublishData { | ||
| /** 发布版本 */ | ||
| versionName: string; | ||
| /** 发布分支 */ | ||
| branch: string; | ||
| /** 最后一次提交的 HASH */ | ||
| lastCommitSha: string; | ||
| } | ||
| export interface PushData { | ||
| /** 当前分支 */ | ||
| branch: string; | ||
| /** 最后一次提交的 HASH */ | ||
| lastCommitSha: string; | ||
| } | ||
| export interface PipelineStorePlatform { | ||
| /** 合并请求数据 */ | ||
| mr: MergeRequestData[]; | ||
| /** 发布数据 */ | ||
| lastPublish: PublishData[]; | ||
| } | ||
| export type PipelineStore = Record<Platform, PipelineStorePlatform>; | ||
| export type CommandOptions = ({ | ||
| kind: 'merge_request'; | ||
| } & MergeRequestData & BaseData) | ({ | ||
| kind: 'publish'; | ||
| } & PublishData & BaseData) | ({ | ||
| kind: 'push'; | ||
| } & PushData & BaseData); | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/trigger/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEtC,MAAM,WAAW,QAAS,SAAQ,SAAS;IACzC,WAAW;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW;IACX,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,WAAW;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,eAAe;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa;IACb,EAAE,EAAE,gBAAgB,EAAE,CAAC;IACvB,WAAW;IACX,WAAW,EAAE,WAAW,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAEpE,MAAM,MAAM,cAAc,GACtB,CAAC;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACzD,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,WAAW,GAAG,QAAQ,CAAC,GAC9C,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/trigger/types.ts"],"names":[],"mappings":""} |
| export declare function mergeEmail(messages: [string, string][]): string; | ||
| //# sourceMappingURL=utils.d.ts.map |
| {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/trigger/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAmBtD"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mergeEmail = void 0; | ||
| function mergeEmail(messages) { | ||
| const map = new Map(); | ||
| for (const [email, message] of messages) { | ||
| if (!map.has(email)) { | ||
| map.set(email, []); | ||
| } | ||
| map.get(email).push(message); | ||
| } | ||
| let lines = []; | ||
| for (const [email, messages] of map.entries()) { | ||
| lines.push(`👉${email}`); | ||
| messages.forEach((item) => lines.push(` | ${item}`)); | ||
| } | ||
| return lines.join('\n'); | ||
| } | ||
| exports.mergeEmail = mergeEmail; | ||
| //# sourceMappingURL=utils.js.map |
| {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/trigger/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAC,QAA4B;IACrD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;IAExC,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,KAAK,GAAa,EAAE,CAAC;IAEzB,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;QACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAnBD,gCAmBC"} |
| /** 合并两个 Unit8Array */ | ||
| export declare function mergeUint8Array(arr1: Uint8Array, arr2: Uint8Array): Uint8Array; | ||
| //# sourceMappingURL=buffer.d.ts.map |
| {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/utils/buffer.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAK9E"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mergeUint8Array = void 0; | ||
| /** 合并两个 Unit8Array */ | ||
| function mergeUint8Array(arr1, arr2) { | ||
| const mergedArr = new Uint8Array(arr1.length + arr2.length); | ||
| mergedArr.set(arr1); | ||
| mergedArr.set(arr2, arr1.length); | ||
| return mergedArr; | ||
| } | ||
| exports.mergeUint8Array = mergeUint8Array; | ||
| //# sourceMappingURL=buffer.js.map |
| {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/utils/buffer.ts"],"names":[],"mappings":";;;AAAA,sBAAsB;AACtB,SAAgB,eAAe,CAAC,IAAgB,EAAE,IAAgB;IAChE,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5D,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,SAAS,CAAC;AACnB,CAAC;AALD,0CAKC"} |
| export declare function runCommand(cmd: string): Promise<string>; | ||
| //# sourceMappingURL=command.d.ts.map |
| {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/utils/command.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,mBAgBrC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.runCommand = void 0; | ||
| const child_process_1 = require("child_process"); | ||
| function runCommand(cmd) { | ||
| return new Promise((resolve, reject) => { | ||
| (0, child_process_1.exec)(cmd, (err, stdout, stderr) => { | ||
| if (err) { | ||
| reject(err); | ||
| return; | ||
| } | ||
| if (stderr) { | ||
| reject(new Error(stderr)); | ||
| return; | ||
| } | ||
| resolve(stdout); | ||
| }); | ||
| }); | ||
| } | ||
| exports.runCommand = runCommand; | ||
| //# sourceMappingURL=command.js.map |
| {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/utils/command.ts"],"names":[],"mappings":";;;AAAA,iDAAqC;AAErC,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAA,oBAAI,EAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAChC,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,GAAG,CAAC,CAAC;gBACZ,OAAO;YACT,CAAC;YAED,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC1B,OAAO;YACT,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAhBD,gCAgBC"} |
| export declare function writeFile(root: string, file: string, content: string): Promise<void>; | ||
| export declare function writeContext<D extends {} = object>(root: string, file: string, context: D): Promise<void>; | ||
| export declare function readFile(file: string): Promise<string | undefined>; | ||
| //# sourceMappingURL=file.d.ts.map |
| {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAI1E;AAED,wBAAsB,YAAY,CAAC,CAAC,SAAS,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,iBAQ/F;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,+BAE1C"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.readFile = exports.writeContext = exports.writeFile = void 0; | ||
| const path_1 = require("path"); | ||
| const promises_1 = require("fs/promises"); | ||
| async function writeFile(root, file, content) { | ||
| const fullPath = (0, path_1.join)(root, file); | ||
| await (0, promises_1.mkdir)((0, path_1.dirname)(fullPath), { recursive: true }); | ||
| await (0, promises_1.writeFile)(fullPath, content); | ||
| } | ||
| exports.writeFile = writeFile; | ||
| async function writeContext(root, file, context) { | ||
| let content = ''; | ||
| for (const [key, value] of Object.entries(context)) { | ||
| content += `${key.toUpperCase()}=${JSON.stringify(value)}\n`; | ||
| } | ||
| return writeFile(root, file, content); | ||
| } | ||
| exports.writeContext = writeContext; | ||
| async function readFile(file) { | ||
| return (0, promises_1.readFile)(file, 'utf-8').catch(() => void 0); | ||
| } | ||
| exports.readFile = readFile; | ||
| //# sourceMappingURL=file.js.map |
| {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":";;;AAAA,+BAAqC;AACrC,0CAAsF;AAE/E,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,IAAY,EAAE,OAAe;IACzE,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,IAAA,gBAAK,EAAC,IAAA,cAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,IAAA,oBAAW,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAJD,8BAIC;AAEM,KAAK,UAAU,YAAY,CAAwB,IAAY,EAAE,IAAY,EAAE,OAAU;IAC9F,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;IAC/D,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AARD,oCAQC;AAEM,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,OAAO,IAAA,mBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACvD,CAAC;AAFD,4BAEC"} |
| import { CreateCommitData, InputFileData, FileData, FileMetaData, CommitActionData, CreateCommitResponseData, CreateMrData, CreateMrResponseData, CreateBranchData, CreateBranchResponseData } from './types'; | ||
| export declare class Gitlab { | ||
| private id; | ||
| private token; | ||
| constructor(id: string, token: string); | ||
| /** 列出当前路径下的所有文件 */ | ||
| listFiles(basePath?: string, ref?: string): Promise<string[]>; | ||
| /** 获取文件 meta 信息 */ | ||
| getFileMetaData(file: string, ref?: string): Promise<FileMetaData>; | ||
| /** 获取文件信息 */ | ||
| getFileData(file: string, ref?: string): Promise<FileData>; | ||
| /** 对比远端和本地文件 */ | ||
| getFilesDiff(remoteFiles: string[], filesInDisk: InputFileData[]): Promise<CommitActionData[]>; | ||
| /** 从文件创建新分支 */ | ||
| createCommitWithFiles(params: Omit<CreateCommitData, 'id'>): Promise<CreateCommitResponseData>; | ||
| /** 创建新分支 */ | ||
| createBranch(params: Omit<CreateBranchData, 'id'>): Promise<CreateBranchResponseData>; | ||
| /** 从分支创建合并请求 */ | ||
| createMrWithBranch(params: Omit<CreateMrData, 'id'>): Promise<CreateMrResponseData>; | ||
| } | ||
| //# sourceMappingURL=api.d.ts.map |
| {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/gitlab/api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAGb,QAAQ,EACR,YAAY,EAEZ,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAIjB,qBAAa,MAAM;IACjB,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,KAAK,CAAS;gBAEV,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKrC,mBAAmB;IACb,SAAS,CAAC,QAAQ,SAAM,EAAE,GAAG,SAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAuClE,mBAAmB;IACb,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAW;IA0BlD,aAAa;IACP,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAW;IAc9C,gBAAgB;IACV,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAsFpG,eAAe;IACT,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC;IAehE,YAAY;IACN,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC;IAevD,gBAAgB;IACV,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;CAc1D"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Gitlab = void 0; | ||
| const axios_1 = __importDefault(require("axios")); | ||
| const constant_1 = require("./constant"); | ||
| const encoding = 'base64'; | ||
| class Gitlab { | ||
| constructor(id, token) { | ||
| this.id = id; | ||
| this.token = token; | ||
| } | ||
| /** 列出当前路径下的所有文件 */ | ||
| async listFiles(basePath = '/', ref = 'master') { | ||
| const files = []; | ||
| const perPage = 40; | ||
| const data = { | ||
| id: this.id, | ||
| ref, | ||
| path: basePath, | ||
| pagination: 'keyset', | ||
| per_page: perPage, | ||
| recursive: true, | ||
| }; | ||
| for (let stop = false; !stop;) { | ||
| const { data: result, headers, ...rest } = await (0, axios_1.default)({ | ||
| ...constant_1.Repositories.Tree(this.id), | ||
| params: data, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| files.push(...result | ||
| .filter((item) => item.type === 'blob') | ||
| .map((item) => item.path)); | ||
| const nextPage = Number(headers['x-next-page']); | ||
| if (Number.isNaN(nextPage) || nextPage === 0) { | ||
| stop = true; | ||
| } | ||
| data.page = nextPage; | ||
| } | ||
| return files; | ||
| } | ||
| /** 获取文件 meta 信息 */ | ||
| async getFileMetaData(file, ref = 'master') { | ||
| const { headers } = await (0, axios_1.default)({ | ||
| ...constant_1.Repositories.FileMeta(this.id)(file), | ||
| params: { | ||
| ref, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| const data = { | ||
| blob_id: headers['x-gitlab-blob-id'], | ||
| content_sha256: headers['x-gitlab-content-sha256'], | ||
| encoding: headers['x-gitlab-encoding'], | ||
| ref: headers['x-gitlab-ref'], | ||
| size: Number(headers['x-gitlab-size']), | ||
| commit_id: headers['x-gitlab-commit-id'], | ||
| last_commit_id: headers['x-gitlab-last-commit-id'], | ||
| file_name: headers['x-gitlab-file-name'], | ||
| file_path: headers['x-gitlab-file-path'], | ||
| }; | ||
| return data; | ||
| } | ||
| /** 获取文件信息 */ | ||
| async getFileData(file, ref = 'master') { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.Repositories.File(this.id)(file), | ||
| params: { | ||
| ref, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| /** 对比远端和本地文件 */ | ||
| async getFilesDiff(remoteFiles, filesInDisk) { | ||
| // TODO: 暂不考虑移动的情况 | ||
| // /** 文件名称相同但文件路径不同 */ | ||
| // const filesWithSameName = remoteFiles | ||
| // .map((remoteFile) => { | ||
| // const baseName = path.basename(remoteFile); | ||
| // const diskFileWithSameBaseName = filesInDisk.find((file) => { | ||
| // return path.basename(file.diskPath) === baseName && file.remotePath !== remoteFile; | ||
| // }); | ||
| // if (diskFileWithSameBaseName) { | ||
| // return { | ||
| // remoteFile, | ||
| // diskFile: diskFileWithSameBaseName, | ||
| // baseName: baseName, | ||
| // }; | ||
| // } | ||
| // }) | ||
| // .filter(<T>(input: T): input is NonNullable<T> => Boolean(input)); | ||
| // // 文件名称相同,判断是否只是移动 | ||
| // for (const file of filesWithSameName) { | ||
| // // .. | ||
| // } | ||
| /** 只在远端的文件 */ | ||
| const filesOnlyInRemote = remoteFiles.filter((file) => !filesInDisk.find((remote) => remote.remotePath === file)); | ||
| /** 只在硬盘里的文件 */ | ||
| const filesOnlyInDisk = filesInDisk.filter(({ remotePath: remote }) => !remoteFiles.includes(remote)); | ||
| /** 同时存在两端的文件 */ | ||
| const filesBothIn = filesInDisk.filter(({ remotePath: remote }) => remoteFiles.includes(remote)); | ||
| /** 更新操作数据 */ | ||
| const actions = []; | ||
| // 只存在于远端的文件要删除 | ||
| await Promise.all(filesOnlyInRemote.map(async (file) => { | ||
| const data = await this.getFileMetaData(file); | ||
| actions.push({ | ||
| action: 'delete', | ||
| last_commit_id: data.last_commit_id, | ||
| file_path: file, | ||
| }); | ||
| })); | ||
| // 只存在于硬盘的文件要创建 | ||
| for (const file of filesOnlyInDisk) { | ||
| actions.push({ | ||
| action: 'create', | ||
| file_path: file.remotePath, | ||
| content: file.content, | ||
| encoding, | ||
| }); | ||
| } | ||
| // 同时存在于这两者的需要更新 | ||
| await Promise.all(filesBothIn.map(async (file) => { | ||
| const meta = await this.getFileMetaData(file.remotePath); | ||
| // 长度不同需要更新 | ||
| if (meta.size !== file.size) { | ||
| actions.push({ | ||
| action: 'update', | ||
| encoding, | ||
| content: file.content, | ||
| file_path: file.remotePath, | ||
| last_commit_id: meta.last_commit_id, | ||
| }); | ||
| return; | ||
| } | ||
| const remoteData = await this.getFileData(file.remotePath); | ||
| // 内容不同需要更新 | ||
| // TODO: encoding 不一样怎么办 | ||
| if (remoteData.content !== file.content) { | ||
| actions.push({ | ||
| action: 'update', | ||
| encoding, | ||
| content: file.content, | ||
| file_path: file.remotePath, | ||
| last_commit_id: meta.last_commit_id, | ||
| }); | ||
| } | ||
| })); | ||
| return actions; | ||
| } | ||
| /** 从文件创建新分支 */ | ||
| async createCommitWithFiles(params) { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.Commit.CreateWithAction(this.id), | ||
| data: { | ||
| id: encodeURIComponent(this.id), | ||
| ...params, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| /** 创建新分支 */ | ||
| async createBranch(params) { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.Branch.Create(this.id), | ||
| data: { | ||
| id: encodeURIComponent(this.id), | ||
| ...params, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| /** 从分支创建合并请求 */ | ||
| async createMrWithBranch(params) { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.MR.CreateWithBranch(this.id), | ||
| data: { | ||
| id: this.id, | ||
| ...params, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| } | ||
| exports.Gitlab = Gitlab; | ||
| //# sourceMappingURL=api.js.map |
| {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/utils/gitlab/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yCAA8D;AAiB9D,MAAM,QAAQ,GAAiB,QAAQ,CAAC;AAExC,MAAa,MAAM;IAIjB,YAAY,EAAU,EAAE,KAAa;QACnC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CA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A,eAAK,EAA2B;YACrD,GAAG,iBAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,IAAI,EAAE;gBACJ,EAAE,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,GAAG,MAAM;aACV;YACD,OAAO,EAAE;gBACP,eAAe,EAAE,IAAI,CAAC,KAAK;aAC5B;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY;IACZ,KAAK,CAAC,YAAY,CAAC,MAAoC;QACrD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,eAAK,EAA2B;YACrD,GAAG,iBAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,IAAI,EAAE;gBACJ,EAAE,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,GAAG,MAAM;aACV;YACD,OAAO,EAAE;gBACP,eAAe,EAAE,IAAI,CAAC,KAAK;aAC5B;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,kBAAkB,CAAC,MAAgC;QACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,eAAK,EAAuB;YACjD,GAAG,aAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,IAAI,EAAE;gBACJ,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,GAAG,MAAM;aACV;YACD,OAAO,EAAE;gBACP,eAAe,EAAE,IAAI,CAAC,KAAK;aAC5B;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAjOD,wBAiOC"} |
| /** | ||
| * 仓库接口 | ||
| */ | ||
| export declare const Repositories: { | ||
| Tree: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| File: (projectId: string) => (file: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| FileMeta: (projectId: string) => (file: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| /** | ||
| * Branch 分支接口 | ||
| */ | ||
| export declare const Branch: { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| Create: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| /** | ||
| * Commit 提交接口 | ||
| */ | ||
| export declare const Commit: { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| CreateWithAction: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| /** | ||
| * MR 提交接口 | ||
| */ | ||
| export declare const MR: { | ||
| /** | ||
| * 创建 MR | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/merge_requests.html#create-mr | ||
| */ | ||
| CreateWithBranch: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| //# sourceMappingURL=constant.d.ts.map |
| {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/utils/gitlab/constant.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,YAAY;sBACL,MAAM;;;;sBAIN,MAAM,YAAY,MAAM;;;;0BAIpB,MAAM,YAAY,MAAM;;;;CAI/C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,MAAM;IACjB;;;;OAIG;wBACiB,MAAM;;;;CAI3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM;IACjB;;;;OAIG;kCAC2B,MAAM;;;;CAIrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,EAAE;IACb;;;;OAIG;kCAC2B,MAAM;;;;CAIrC,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.MR = exports.Commit = exports.Branch = exports.Repositories = void 0; | ||
| const BaseUrl = 'https://g.hz.netease.com/api/v4'; | ||
| /** | ||
| * 仓库接口 | ||
| */ | ||
| exports.Repositories = { | ||
| Tree: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/tree`, | ||
| method: 'GET', | ||
| }), | ||
| File: (projectId) => (file) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/files/${encodeURIComponent(file)}`, | ||
| method: 'GET', | ||
| }), | ||
| FileMeta: (projectId) => (file) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/files/${encodeURIComponent(file)}`, | ||
| method: 'HEAD', | ||
| }), | ||
| }; | ||
| /** | ||
| * Branch 分支接口 | ||
| */ | ||
| exports.Branch = { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| Create: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/branches`, | ||
| method: 'POST', | ||
| }), | ||
| }; | ||
| /** | ||
| * Commit 提交接口 | ||
| */ | ||
| exports.Commit = { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| CreateWithAction: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/commits`, | ||
| method: 'POST', | ||
| }), | ||
| }; | ||
| /** | ||
| * MR 提交接口 | ||
| */ | ||
| exports.MR = { | ||
| /** | ||
| * 创建 MR | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/merge_requests.html#create-mr | ||
| */ | ||
| CreateWithBranch: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/merge_requests`, | ||
| method: 'POST', | ||
| }), | ||
| }; | ||
| //# sourceMappingURL=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AAEF;;GAEG;AACU,QAAA,EAAE,GAAG;IAChB;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC;QACxC,GAAG,EAAE,GAAG,OAAO,aAAa,kBAAkB,CAAC,SAAS,CAAC,iBAAiB;QAC1E,MAAM,EAAE,MAAM;KACf,CAAC;CACH,CAAC"} |
| export * from './api'; | ||
| export * from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/gitlab/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./api"), exports); | ||
| __exportStar(require("./types"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/gitlab/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,0CAAwB"} |
| export type FileEncoding = 'text' | 'base64'; | ||
| /** | ||
| * 项目访问密钥 | ||
| * | ||
| * @link https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html | ||
| */ | ||
| export interface GitlabTokenData { | ||
| tokenId: string; | ||
| } | ||
| /** | ||
| * 项目数据 | ||
| */ | ||
| export interface Project { | ||
| /** | ||
| * 项目编号/路径 | ||
| * | ||
| * @description 路径就是指项目的网址,比如项目网址是`https://g.hz.netease.com/vusion/cache-script`,那么这里的 id 就是`vusion%2Fcache-script`,反斜杠要转义。 | ||
| */ | ||
| id: number | string; | ||
| } | ||
| interface CreateCommitBaseData extends Project { | ||
| /** | ||
| * 提交信息 | ||
| */ | ||
| commit_message: string; | ||
| /** | ||
| * 当前提交的行为 | ||
| */ | ||
| actions: CommitActionData[]; | ||
| /** | ||
| * 作者邮箱 | ||
| */ | ||
| author_email?: string; | ||
| /** | ||
| * 作者姓名 | ||
| */ | ||
| author_name?: string; | ||
| /** | ||
| * 提交状态 | ||
| * | ||
| * @default true | ||
| */ | ||
| stats?: boolean; | ||
| /** | ||
| * 强行提交 | ||
| * | ||
| * @description `true`的时候将会覆盖掉`start_branch`和`start_sha`的提交信息 | ||
| */ | ||
| force?: boolean; | ||
| } | ||
| interface CreateCommitExistBranch extends CreateCommitBaseData { | ||
| /** | ||
| * 当前提交的基点分支 | ||
| */ | ||
| branch: string; | ||
| } | ||
| /** 提交数据 */ | ||
| export type CreateCommitData = CreateCommitExistBranch; | ||
| interface CommitBaseData { | ||
| /** | ||
| * 文件路径 | ||
| */ | ||
| file_path: string; | ||
| /** | ||
| * 编码方式 | ||
| * | ||
| * @default 'text' | ||
| */ | ||
| encoding?: FileEncoding; | ||
| } | ||
| interface CommitCreateActionData extends CommitBaseData { | ||
| /** | ||
| * 创建文件 | ||
| */ | ||
| action: 'create'; | ||
| /** | ||
| * 文件内容 | ||
| */ | ||
| content: string; | ||
| } | ||
| interface CommitDeleteActionData extends CommitBaseData { | ||
| /** | ||
| * 删除文件 | ||
| */ | ||
| action: 'delete'; | ||
| /** | ||
| * 文件上次提交的编号 | ||
| */ | ||
| last_commit_id: string; | ||
| } | ||
| interface CommitMoveActionData extends CommitBaseData { | ||
| /** | ||
| * 移动文件 | ||
| */ | ||
| action: 'move'; | ||
| /** | ||
| * 文件之前的路径 | ||
| */ | ||
| previous_path: string; | ||
| /** | ||
| * 文件上次提交的编号 | ||
| */ | ||
| last_commit_id: string; | ||
| } | ||
| interface CommitUpdateActionData extends CommitBaseData { | ||
| /** | ||
| * 更新文件 | ||
| */ | ||
| action: 'update'; | ||
| /** | ||
| * 文件内容 | ||
| */ | ||
| content: string; | ||
| /** | ||
| * 文件上次提交的编号 | ||
| */ | ||
| last_commit_id: string; | ||
| } | ||
| interface CommitChmodActionData extends CommitBaseData { | ||
| /** | ||
| * 更新文件 | ||
| */ | ||
| action: 'chmod'; | ||
| /** | ||
| * 文件能否被执行 | ||
| */ | ||
| execute_filemode: boolean; | ||
| } | ||
| /** 提交行为数据 */ | ||
| export type CommitActionData = CommitCreateActionData | CommitDeleteActionData | CommitMoveActionData | CommitUpdateActionData | CommitChmodActionData; | ||
| export interface LsTreeData extends Project { | ||
| /** | ||
| * 检出文件的基路径 | ||
| * | ||
| * @default '/' | ||
| */ | ||
| path?: string; | ||
| /** | ||
| * 递归检出所有文件 | ||
| * | ||
| * @default false | ||
| */ | ||
| recursive?: boolean; | ||
| /** | ||
| * 是否启用分页 | ||
| * | ||
| * @default 'keyset' | ||
| */ | ||
| pagination?: 'keyset'; | ||
| /** | ||
| * 使用分页时每页的文件数量 | ||
| * | ||
| * @default 20 | ||
| */ | ||
| per_page?: number; | ||
| /** | ||
| * 下一页标记 | ||
| * | ||
| * @description 此值保存在返回值的`headers`里,字段为`x-next-page` | ||
| * @link https://docs.gitlab.com/ee/api/rest/index.html#other-pagination-headers | ||
| * @description gitlab 升级到 15 之后,此字段将会改为`page_token` | ||
| * @link https://docs.gitlab.com/ee/api/repositories.html#list-repository-tree | ||
| * | ||
| */ | ||
| page?: number; | ||
| /** | ||
| * 检出文件所在的分支或者是标签 | ||
| * | ||
| * @default 默认分支 | ||
| */ | ||
| ref?: string; | ||
| } | ||
| export interface LsTreeItemData { | ||
| id: string; | ||
| name: string; | ||
| path: string; | ||
| type: 'blob' | 'tree'; | ||
| mode: '100644' | '040000'; | ||
| } | ||
| export interface FileMetaData { | ||
| blob_id: string; | ||
| content_sha256: string; | ||
| encoding: FileEncoding; | ||
| ref: string; | ||
| size: number; | ||
| commit_id: string; | ||
| last_commit_id: string; | ||
| file_name: string; | ||
| file_path: string; | ||
| } | ||
| export interface FileData extends FileMetaData { | ||
| content: string; | ||
| execute_filemode: string; | ||
| } | ||
| /** 文件数据 */ | ||
| export interface InputFileData { | ||
| /** 文件硬盘路径 */ | ||
| diskPath: string; | ||
| /** 文件远端路径 */ | ||
| remotePath: string; | ||
| /** | ||
| * 文件内容 | ||
| * | ||
| * @description base64 编码 | ||
| */ | ||
| content: string; | ||
| /** | ||
| * 文件大小 | ||
| */ | ||
| size: number; | ||
| } | ||
| export interface CreateCommitResponseData { | ||
| id: string; | ||
| short_id: string; | ||
| title: string; | ||
| author_name: string; | ||
| author_email: string; | ||
| committer_name: string; | ||
| committer_email: string; | ||
| created_at: string; | ||
| message: string; | ||
| parent_ids: string[]; | ||
| committed_date: string; | ||
| authored_date: string; | ||
| stats: { | ||
| additions: number; | ||
| deletions: number; | ||
| total: number; | ||
| }; | ||
| status: null; | ||
| web_url: string; | ||
| } | ||
| export interface CreateMrData extends Project { | ||
| source_branch: string; | ||
| target_branch: string; | ||
| title: string; | ||
| allow_collaboration?: boolean; | ||
| /** allow_collaboration 的别名 */ | ||
| allow_maintainer_to_push?: boolean; | ||
| assignee_id?: number; | ||
| assignee_ids?: number[]; | ||
| description?: string; | ||
| /** | ||
| * MR 的标签 | ||
| * | ||
| * @description 使用分号分割 | ||
| */ | ||
| labels?: string; | ||
| milestone_id?: number; | ||
| remove_source_branch?: boolean; | ||
| reviewer_ids?: number; | ||
| /** MR 是否使用压缩提交 */ | ||
| squash?: boolean; | ||
| /** 目标项目 */ | ||
| target_project_id?: string; | ||
| } | ||
| export interface CreateMrResponseData extends Project { | ||
| id: number; | ||
| iid: number; | ||
| project_id: number; | ||
| title: string; | ||
| description: string; | ||
| state: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| target_branch: string; | ||
| source_branch: string; | ||
| upvotes: number; | ||
| downvotes: number; | ||
| author: { | ||
| id: number; | ||
| name: string; | ||
| username: string; | ||
| state: string; | ||
| avatar_url?: string; | ||
| web_url: string; | ||
| }; | ||
| assignee: { | ||
| id: number; | ||
| name: string; | ||
| username: string; | ||
| state: string; | ||
| avatar_url?: string; | ||
| web_url: string; | ||
| }; | ||
| source_project_id: number; | ||
| target_project_id: number; | ||
| labels: string[]; | ||
| draft: boolean; | ||
| work_in_progress: boolean; | ||
| milestone: { | ||
| id: number; | ||
| iid: number; | ||
| project_id: number; | ||
| title: string; | ||
| description: string; | ||
| state: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| due_date: string; | ||
| start_date: string; | ||
| web_url: string; | ||
| }; | ||
| merge_when_pipeline_succeeds: boolean; | ||
| merge_status: string; | ||
| detailed_merge_status: string; | ||
| merge_error?: string; | ||
| sha: string; | ||
| merge_commit_sha?: string; | ||
| squash_commit_sha?: string; | ||
| user_notes_count: number; | ||
| discussion_locked?: string; | ||
| should_remove_source_branch: boolean; | ||
| force_remove_source_branch: boolean; | ||
| allow_collaboration: boolean; | ||
| allow_maintainer_to_push: boolean; | ||
| web_url: string; | ||
| references: { | ||
| short: string; | ||
| relative: string; | ||
| full: string; | ||
| }; | ||
| time_stats: { | ||
| time_estimate: number; | ||
| total_time_spent: number; | ||
| human_time_estimate?: string; | ||
| human_total_time_spent?: string; | ||
| }; | ||
| squash: boolean; | ||
| subscribed: boolean; | ||
| changes_count: string; | ||
| merge_user: { | ||
| id: number; | ||
| name: string; | ||
| username: string; | ||
| state: string; | ||
| avatar_url: string; | ||
| web_url: string; | ||
| }; | ||
| merged_at: string; | ||
| prepared_at: string; | ||
| closed_by?: string; | ||
| closed_at?: string; | ||
| latest_build_started_at: string; | ||
| latest_build_finished_at: string; | ||
| first_deployed_to_production_at?: string; | ||
| pipeline: { | ||
| id: number; | ||
| sha: string; | ||
| ref: string; | ||
| status: string; | ||
| web_url: string; | ||
| }; | ||
| diff_refs: { | ||
| base_sha: string; | ||
| head_sha: string; | ||
| start_sha: string; | ||
| }; | ||
| diverged_commits_count: number; | ||
| task_completion_status: { | ||
| count: number; | ||
| completed_count: number; | ||
| }; | ||
| } | ||
| export interface CreateBranchData extends Project { | ||
| /** 新分支的名称 */ | ||
| branch: string; | ||
| /** 基准分支 */ | ||
| ref: string; | ||
| } | ||
| export interface CreateBranchResponseData extends Project { | ||
| commit: { | ||
| id: string; | ||
| short_id: string; | ||
| created_at: string; | ||
| parent_ids: string[]; | ||
| title: string; | ||
| message: string; | ||
| author_name: string; | ||
| author_email: string; | ||
| authored_date: string; | ||
| committer_name: string; | ||
| committer_email: string; | ||
| committed_date: string; | ||
| "trailers": {}; | ||
| web_url: string; | ||
| }; | ||
| name: string; | ||
| merged: boolean; | ||
| protected: boolean; | ||
| default: boolean; | ||
| developers_can_push: boolean; | ||
| developers_can_merge: boolean; | ||
| can_push: boolean; | ||
| web_url: string; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/gitlab/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED,UAAU,oBAAqB,SAAQ,OAAO;IAC5C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;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O,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const abc = { | ||
| commit_message: '', | ||
| branch: '', | ||
| actions: [], | ||
| }; | ||
| function test(datra) { } | ||
| test(abc); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/gitlab/types.ts"],"names":[],"mappings":";;AA8EA,MAAM,GAAG,GAAG;IACV,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,SAAS,IAAI,CAAC,KAAmC,IAAG,CAAC;AAErD,IAAI,CAAC,GAAG,CAAC,CAAC"} |
| export * from './log'; | ||
| export * from './secret'; | ||
| export * from './string'; | ||
| export * from './time'; | ||
| export * from './object'; | ||
| export * from './buffer'; | ||
| export * from './command'; | ||
| export * from './project'; | ||
| export * from './file'; | ||
| export * from './gitlab'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./log"), exports); | ||
| __exportStar(require("./secret"), exports); | ||
| __exportStar(require("./string"), exports); | ||
| __exportStar(require("./time"), exports); | ||
| __exportStar(require("./object"), exports); | ||
| __exportStar(require("./buffer"), exports); | ||
| __exportStar(require("./command"), exports); | ||
| __exportStar(require("./project"), exports); | ||
| __exportStar(require("./file"), exports); | ||
| __exportStar(require("./gitlab"), exports); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB"} |
| import chalk from 'chalk'; | ||
| import createSpinner from 'ora'; | ||
| export declare const color: chalk.Chalk; | ||
| export declare const logger: import("pino").Logger<{ | ||
| msgPrefix: string; | ||
| transport: { | ||
| target: string; | ||
| }; | ||
| }>; | ||
| export declare const spinner: createSpinner.Ora; | ||
| //# sourceMappingURL=log.d.ts.map |
| {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,aAAa,MAAM,KAAK,CAAC;AAEhC,eAAO,MAAM,KAAK,aAEhB,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;EAKjB,CAAC;AAEH,eAAO,MAAM,OAAO,mBAGlB,CAAC"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.spinner = exports.logger = exports.color = void 0; | ||
| const pino_1 = __importDefault(require("pino")); | ||
| const chalk_1 = __importDefault(require("chalk")); | ||
| const ora_1 = __importDefault(require("ora")); | ||
| exports.color = new chalk_1.default.Instance({ | ||
| level: 3, | ||
| }); | ||
| exports.logger = (0, pino_1.default)({ | ||
| msgPrefix: chalk_1.default.green('[LCAP Tool] '), | ||
| transport: { | ||
| target: 'pino-pretty', | ||
| }, | ||
| }); | ||
| exports.spinner = (0, ora_1.default)({ | ||
| interval: 200, | ||
| color: 'blue', | ||
| }); | ||
| //# sourceMappingURL=log.js.map |
| {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,kDAA0B;AAC1B,8CAAgC;AAEnB,QAAA,KAAK,GAAG,IAAI,eAAK,CAAC,QAAQ,CAAC;IACtC,KAAK,EAAE,CAAC;CACT,CAAC,CAAC;AAEU,QAAA,MAAM,GAAG,IAAA,cAAI,EAAC;IACzB,SAAS,EAAE,eAAK,CAAC,KAAK,CAAC,cAAc,CAAC;IACtC,SAAS,EAAE;QACT,MAAM,EAAE,aAAa;KACtB;CACF,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,IAAA,aAAa,EAAC;IACnC,QAAQ,EAAE,GAAG;IACb,KAAK,EAAE,MAAM;CACd,CAAC,CAAC"} |
| export declare function shallowEqual<T extends Record<string, any>>(obj1: T, obj2: T): boolean; | ||
| //# sourceMappingURL=object.d.ts.map |
| {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAcrF"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.shallowEqual = void 0; | ||
| function shallowEqual(obj1, obj2) { | ||
| if (obj1 === obj2) { | ||
| return true; | ||
| } | ||
| const keys1 = Object.keys(obj1); | ||
| const keys2 = Object.keys(obj2); | ||
| // 如果两个对象的属性数量不同,则不相等 | ||
| if (keys1.length !== keys2.length) { | ||
| return false; | ||
| } | ||
| return keys1.every(key => obj1[key] === obj2[key]); | ||
| } | ||
| exports.shallowEqual = shallowEqual; | ||
| //# sourceMappingURL=object.js.map |
| {"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAgC,IAAO,EAAE,IAAO;IAC1E,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhC,qBAAqB;IACrB,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC;AAdD,oCAcC"} |
| export declare function getVersion(root: string): Promise<string>; | ||
| //# sourceMappingURL=project.d.ts.map |
| {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,mBAI5C"} |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getVersion = void 0; | ||
| const path_1 = __importDefault(require("path")); | ||
| const promises_1 = require("fs/promises"); | ||
| async function getVersion(root) { | ||
| const packageJson = await (0, promises_1.readFile)(path_1.default.join(root, 'package.json'), 'utf-8'); | ||
| const { version } = JSON.parse(packageJson); | ||
| return version; | ||
| } | ||
| exports.getVersion = getVersion; | ||
| //# sourceMappingURL=project.js.map |
| {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0CAAuC;AAEhC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,MAAM,WAAW,GAAG,MAAM,IAAA,mBAAQ,EAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAwB,CAAC;IACnE,OAAO,OAAO,CAAC;AACjB,CAAC;AAJD,gCAIC"} |
| import type { Arguments } from 'yargs'; | ||
| export interface TokenData { | ||
| /** 发布密钥 */ | ||
| token?: string; | ||
| /** 发布密钥所在文件 */ | ||
| tokenFile?: string; | ||
| } | ||
| export declare function getSecretByFile<T>(file: string): Promise<T>; | ||
| export declare function getSecretByToken<T>(token: string): T; | ||
| export declare function transformSecretToToken(data: object): string; | ||
| export declare const tokenOptions: { | ||
| readonly token: { | ||
| readonly type: "string"; | ||
| readonly describe: "发布密钥"; | ||
| }; | ||
| readonly tokenFile: { | ||
| readonly type: "string"; | ||
| readonly describe: "发布密钥所在文件"; | ||
| }; | ||
| }; | ||
| export declare function tokenCheck(argv: Arguments<TokenData>): boolean; | ||
| export declare function getSecretByOption<T>(root: string, opt: TokenData): Promise<T>; | ||
| //# sourceMappingURL=secret.d.ts.map |
| {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../src/utils/secret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,SAAS;IACxB,WAAW;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAE3D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAEpD;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,UAElD;AAED,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAA;AAEV,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,WAMpD;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAMnF"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getSecretByOption = exports.tokenCheck = exports.tokenOptions = exports.transformSecretToToken = exports.getSecretByToken = exports.getSecretByFile = void 0; | ||
| const promises_1 = require("fs/promises"); | ||
| const path_1 = require("path"); | ||
| function getSecretByFile(file) { | ||
| return (0, promises_1.readFile)(file, 'utf-8').then((val) => JSON.parse(val)); | ||
| } | ||
| exports.getSecretByFile = getSecretByFile; | ||
| function getSecretByToken(token) { | ||
| return JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); | ||
| } | ||
| exports.getSecretByToken = getSecretByToken; | ||
| function transformSecretToToken(data) { | ||
| return Buffer.from(JSON.stringify(data)).toString('base64'); | ||
| } | ||
| exports.transformSecretToToken = transformSecretToToken; | ||
| exports.tokenOptions = { | ||
| token: { | ||
| type: 'string', | ||
| describe: '发布密钥', | ||
| }, | ||
| tokenFile: { | ||
| type: 'string', | ||
| describe: '发布密钥所在文件', | ||
| }, | ||
| }; | ||
| function tokenCheck(argv) { | ||
| if (!argv.token && !argv.tokenFile) { | ||
| throw new Error('以下参数至少需要填入一个:token, tokenFile'); | ||
| } | ||
| return true; | ||
| } | ||
| exports.tokenCheck = tokenCheck; | ||
| async function getSecretByOption(root, opt) { | ||
| return opt.token | ||
| ? getSecretByToken(opt.token) | ||
| : getSecretByFile((0, path_1.isAbsolute)(opt.tokenFile) ? opt.tokenFile : (0, path_1.join)(root, opt.tokenFile)); | ||
| } | ||
| exports.getSecretByOption = getSecretByOption; | ||
| //# sourceMappingURL=secret.js.map |
| {"version":3,"file":"secret.js","sourceRoot":"","sources":["../../src/utils/secret.ts"],"names":[],"mappings":";;;AAAA,0CAAuC;AACvC,+BAAwC;AAUxC,SAAgB,eAAe,CAAI,IAAY;IAC7C,OAAO,IAAA,mBAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC;AAFD,0CAEC;AAED,SAAgB,gBAAgB,CAAI,KAAa;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,4CAEC;AAED,SAAgB,sBAAsB,CAAC,IAAY;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAFD,wDAEC;AAEY,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE;QACL,IAAI,EAAE,QAAiB;QACvB,QAAQ,EAAE,MAAM;KACjB;IACD,SAAS,EAAE;QACT,IAAI,EAAE,QAAiB;QACvB,QAAQ,EAAE,UAAU;KACrB;CACO,CAAA;AAEV,SAAgB,UAAU,CAAC,IAA0B;IACnD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAND,gCAMC;AAEM,KAAK,UAAU,iBAAiB,CAAI,IAAY,EAAE,GAAc;IACrE,OAAO,GAAG,CAAC,KAAK;QACd,CAAC,CAAC,gBAAgB,CAAI,GAAG,CAAC,KAAK,CAAC;QAChC,CAAC,CAAC,eAAe,CACb,IAAA,iBAAU,EAAC,GAAG,CAAC,SAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAU,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,GAAG,CAAC,SAAU,CAAC,CACzE,CAAC;AACR,CAAC;AAND,8CAMC"} |
| /** 分支名称格式化 */ | ||
| export declare function formatBranch(name: string): string; | ||
| /** 文本格式化 */ | ||
| export declare function formatMessage(message: string): string; | ||
| /** 格式化文本 */ | ||
| export declare function formatMessageByParams(input: string, data: Record<string, string | number>): string; | ||
| //# sourceMappingURL=string.d.ts.map |
| {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAExC;AAED,YAAY;AACZ,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,UAE5C;AAED,YAAY;AACZ,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,UAQzF"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatMessageByParams = exports.formatMessage = exports.formatBranch = void 0; | ||
| /** 分支名称格式化 */ | ||
| function formatBranch(name) { | ||
| return name.replace(/[^\w]+/g, '-'); | ||
| } | ||
| exports.formatBranch = formatBranch; | ||
| /** 文本格式化 */ | ||
| function formatMessage(message) { | ||
| return message.replace(/\\+n/g, '\n'); | ||
| } | ||
| exports.formatMessage = formatMessage; | ||
| /** 格式化文本 */ | ||
| function formatMessageByParams(input, data) { | ||
| let content = input; | ||
| for (const key of Object.keys(data)) { | ||
| content = content.replace(`[${key}]`, String(data[key])); | ||
| } | ||
| return formatMessage(content); | ||
| } | ||
| exports.formatMessageByParams = formatMessageByParams; | ||
| //# sourceMappingURL=string.js.map |
| {"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC;AAFD,oCAEC;AAED,YAAY;AACZ,SAAgB,aAAa,CAAC,OAAe;IAC3C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAFD,sCAEC;AAED,YAAY;AACZ,SAAgB,qBAAqB,CAAC,KAAa,EAAE,IAAqC;IACxF,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AARD,sDAQC"} |
| export declare const delay: (time?: number) => Promise<void>; | ||
| //# sourceMappingURL=time.d.ts.map |
| {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAW,MAAM,kBAIlC,CAAC"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.delay = void 0; | ||
| const delay = (time) => { | ||
| return new Promise((resolve) => { | ||
| setTimeout(resolve, time); | ||
| }); | ||
| }; | ||
| exports.delay = delay; | ||
| //# sourceMappingURL=time.js.map |
| {"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/utils/time.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,EAAE;IACrC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB"} |
+1
-1
| #!/usr/bin/env node | ||
| require('../dist').run(); | ||
| require('../out').run(); |
+8
-14
| { | ||
| "name": "@lcap/cli", | ||
| "version": "2.3.6", | ||
| "version": "2.4.0-beta.1", | ||
| "description": "utils for lcap", | ||
| "author": "sufangzhou", | ||
| "license": "MIT", | ||
| "main": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "main": "out/index.js", | ||
| "types": "out/index.d.ts", | ||
| "bin": { | ||
@@ -15,3 +15,3 @@ "lcap2": "./bin/index.js" | ||
| "README.md", | ||
| "dist", | ||
| "out", | ||
| "bin" | ||
@@ -25,6 +25,2 @@ ], | ||
| ], | ||
| "engines": { | ||
| "node": ">=18", | ||
| "pnpm": ">=9" | ||
| }, | ||
| "devDependencies": { | ||
@@ -35,10 +31,8 @@ "@types/mime": "3.0.1", | ||
| "@types/yargs": "17.0.24", | ||
| "@xiao-ai/eslint-config": "1.0.1", | ||
| "@xiao-ai/tsconfig": "1.0.3", | ||
| "eslint": "8.45.0", | ||
| "rimraf": "5.0.1", | ||
| "typescript": "5.2.2" | ||
| "rimraf": "5.0.5", | ||
| "typescript": "5.4.4", | ||
| "@lcap/nasl-tsconfig": "1.0.1" | ||
| }, | ||
| "dependencies": { | ||
| "axios": "1.5.0", | ||
| "axios": "1.6.2", | ||
| "chalk": "4.1.2", | ||
@@ -45,0 +39,0 @@ "mime": "3.0.0", |
| export declare function run(): void; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.run = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const yargs_1 = tslib_1.__importDefault(require("yargs")); | ||
| const publish_1 = require("../publish"); | ||
| const popo_1 = require("../popo"); | ||
| const trigger_1 = require("../trigger"); | ||
| const release_1 = require("../release"); | ||
| function run() { | ||
| (0, publish_1.registerCommand)(yargs_1.default); | ||
| (0, popo_1.registerCommand)(yargs_1.default); | ||
| (0, trigger_1.registerCommand)(yargs_1.default); | ||
| (0, release_1.registerCommand)(yargs_1.default); | ||
| yargs_1.default | ||
| .strict() | ||
| .showHelpOnFail(false).argv; | ||
| } | ||
| exports.run = run; |
| export * from './cli'; | ||
| export * as publish from './publish'; | ||
| export * as popo from './popo'; | ||
| export * as trigger from './trigger'; | ||
| export * as release from './release'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.release = exports.trigger = exports.popo = exports.publish = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./cli"), exports); | ||
| exports.publish = tslib_1.__importStar(require("./publish")); | ||
| exports.popo = tslib_1.__importStar(require("./popo")); | ||
| exports.trigger = tslib_1.__importStar(require("./trigger")); | ||
| exports.release = tslib_1.__importStar(require("./release")); |
| import axios from 'axios'; | ||
| import { SecretData, MessageData } from './types'; | ||
| export declare function fetchToken(token: SecretData): Promise<string>; | ||
| /** 对单人发消息 */ | ||
| export declare function postRobotP2P(token: string, body: MessageData): Promise<axios.AxiosResponse<any, any>>; | ||
| /** 群发消息 */ | ||
| export declare function postRobotTeam(token: string, body: MessageData): Promise<axios.AxiosResponse<any, any>>; | ||
| /** | ||
| * 通过邮箱反查用户名称 | ||
| */ | ||
| export declare function getPersonName(token: string, email: string): Promise<string | undefined>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getPersonName = exports.postRobotTeam = exports.postRobotP2P = exports.fetchToken = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const axios_1 = tslib_1.__importDefault(require("axios")); | ||
| const constant_1 = require("./constant"); | ||
| const utils_1 = require("../utils"); | ||
| function fetchToken(token) { | ||
| return axios_1.default | ||
| .post(constant_1.PopoApi.GetToken, { | ||
| appId: token.id, | ||
| appSecret: token.secret, | ||
| }, { | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }) | ||
| .then(({ data }) => { | ||
| return data.data.openAccessToken; | ||
| }); | ||
| } | ||
| exports.fetchToken = fetchToken; | ||
| /** 对单人发消息 */ | ||
| async function postRobotP2P(token, body) { | ||
| const data = { | ||
| sender: body.sender, | ||
| receiver: body.receiver, | ||
| message: (0, utils_1.formatMessage)(body.message), | ||
| }; | ||
| return axios_1.default.post(constant_1.PopoApi.ToPerson, data, { | ||
| headers: { | ||
| 'Open-Access-Token': token, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
| } | ||
| exports.postRobotP2P = postRobotP2P; | ||
| /** 群发消息 */ | ||
| async function postRobotTeam(token, body) { | ||
| const data = { | ||
| sender: body.sender, | ||
| receiver: body.receiver, | ||
| message: (0, utils_1.formatMessage)(body.message), | ||
| atUids: [], | ||
| isAtAll: false, | ||
| }; | ||
| if (data.message.includes('@所有人')) { | ||
| data.isAtAll = true; | ||
| } | ||
| const emails = (data.message.match(/@[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+(\.[a-zA-Z]+)+/g) ?? []) | ||
| .map((email) => email.substring(1)); | ||
| if (emails && emails.length > 0) { | ||
| const names = await Promise.all(emails.map((email) => getPersonName(token, email))); | ||
| for (let i = 0; i < emails.length; i++) { | ||
| const email = emails[i]; | ||
| const name = names[i]; | ||
| if (email && name && typeof name === 'string') { | ||
| data.message = data.message.replace(`@${email}`, `@${name}`); | ||
| data.atUids.push(email); | ||
| } | ||
| } | ||
| } | ||
| return axios_1.default.post(constant_1.PopoApi.ToTeam, data, { | ||
| headers: { | ||
| 'Open-Access-Token': token, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
| } | ||
| exports.postRobotTeam = postRobotTeam; | ||
| /** | ||
| * 通过邮箱反查用户名称 | ||
| */ | ||
| async function getPersonName(token, email) { | ||
| return axios_1.default | ||
| .get(constant_1.PopoApi.GetPerson, { | ||
| params: { | ||
| email, | ||
| }, | ||
| headers: { | ||
| 'Open-Access-Token': token, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }) | ||
| .then(({ data }) => data.data.name) | ||
| .catch(() => void 0); | ||
| } | ||
| exports.getPersonName = getPersonName; |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const sender_1 = require("./sender"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('message', '发送 POPO 消息', | ||
| // @ts-ignore | ||
| (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('kind', { | ||
| type: 'string', | ||
| describe: '消息类别', | ||
| choices: ['person', 'team'], | ||
| demandOption: true, | ||
| }) | ||
| .option('receiver', { | ||
| type: 'string', | ||
| describe: '接收消息的人或者群', | ||
| demandOption: true, | ||
| }) | ||
| .option('message', { | ||
| type: 'string', | ||
| describe: '消息文本', | ||
| demandOption: true, | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, sender_1.sendMessage)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; |
| /** | ||
| * POPO 公共 API | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export declare const PopoApi: { | ||
| GetToken: string; | ||
| GetPerson: string; | ||
| ToTeam: string; | ||
| ToPerson: string; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.PopoApi = void 0; | ||
| /** | ||
| * POPO 公共 API | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| exports.PopoApi = { | ||
| GetToken: 'https://open.popo.netease.com/open-apis/token', | ||
| GetPerson: 'https://open.popo.netease.com/open-apis/corp/v1/employee', | ||
| ToTeam: 'https://open.popo.netease.com/open-apis/robot/v1/team', | ||
| ToPerson: 'https://open.popo.netease.com/open-apis/robot/v1/p2p', | ||
| }; |
| export { registerCommand } from './command'; | ||
| export * from './api'; | ||
| export * from './sender'; | ||
| export * from './types'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); | ||
| tslib_1.__exportStar(require("./api"), exports); | ||
| tslib_1.__exportStar(require("./sender"), exports); | ||
| tslib_1.__exportStar(require("./types"), exports); |
| import { CommandOptions } from './types'; | ||
| export declare function sendMessage(root: string, opt: CommandOptions): Promise<void>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.sendMessage = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const api_1 = require("./api"); | ||
| async function sendMessage(root, opt) { | ||
| const secret = await (0, utils_1.getSecretByOption)(root, opt); | ||
| const token = await (0, api_1.fetchToken)(secret); | ||
| const data = { | ||
| ...opt, | ||
| sender: secret.sender, | ||
| }; | ||
| if (opt.kind === 'person') { | ||
| (0, api_1.postRobotP2P)(token, data); | ||
| } | ||
| else { | ||
| (0, api_1.postRobotTeam)(token, data); | ||
| } | ||
| } | ||
| exports.sendMessage = sendMessage; |
| import type { TokenData } from '../utils'; | ||
| /** | ||
| * POPO 群消息数据 | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export interface TeamMessageData { | ||
| /** 机器人账号 */ | ||
| sender: string; | ||
| /** | ||
| * 群号 | ||
| * | ||
| * @description 机器人必须在群内 | ||
| */ | ||
| receiver: string; | ||
| /** | ||
| * 消息内容 | ||
| * | ||
| * @description 不能超过 3000 个字符 | ||
| */ | ||
| message: string; | ||
| /** | ||
| * 提醒的成员列表 | ||
| * | ||
| * @description 成员只有在群内才生效 | ||
| * @description 文本中含有被圈的人的名称才有效 | ||
| */ | ||
| atUids?: string[]; | ||
| /** | ||
| * 是否提醒所有人 | ||
| * | ||
| * @description 群消息时有效 | ||
| * @description 消息文本中必须要有`'@所有人'`才有效 | ||
| * @default false | ||
| */ | ||
| isAtAll?: boolean; | ||
| } | ||
| /** | ||
| * POPO 个人消息数据 | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export interface PersonMessageData { | ||
| /** 机器人账号 */ | ||
| sender: string; | ||
| /** 接受消息的用户邮箱 */ | ||
| receiver: string; | ||
| /** | ||
| * 消息内容 | ||
| * | ||
| * @description 不能超过 3000 个字符 | ||
| */ | ||
| message: string; | ||
| } | ||
| /** | ||
| * 授权凭证返回接口 | ||
| * | ||
| * @link https://open.popo.netease.com/docs/api/robot/msg-send | ||
| */ | ||
| export interface TokenResponseData { | ||
| openAccessToken: string; | ||
| accessExpiredAt: number; | ||
| } | ||
| export interface MessageData { | ||
| /** 机器人账号 */ | ||
| sender: string; | ||
| /** | ||
| * 接收消息方标志符 | ||
| * | ||
| * - 个人状态时,此项为个人邮箱 | ||
| * - 群状态时,此项为群号 | ||
| */ | ||
| receiver: string; | ||
| /** | ||
| * 消息文本 | ||
| */ | ||
| message: string; | ||
| } | ||
| export interface CommandOptions extends TokenData, Omit<MessageData, 'sender'> { | ||
| /** 消息类别 */ | ||
| kind: 'person' | 'team'; | ||
| } | ||
| export interface SecretData { | ||
| id: string; | ||
| secret: string; | ||
| sender: string; | ||
| } | ||
| export interface PersonDetail { | ||
| /** 邮箱账号 */ | ||
| uid: string; | ||
| /** 工号 */ | ||
| jobNumber: string; | ||
| /** 姓名 */ | ||
| name: string; | ||
| /** 花名 */ | ||
| nickname: string; | ||
| /** 分机号 */ | ||
| extendTel: string; | ||
| /** 区域名称 */ | ||
| areaName: string; | ||
| /** 办公地点 */ | ||
| locationName: string; | ||
| /** 办公楼层 */ | ||
| floorName: string; | ||
| /** 部门名称 */ | ||
| deptNameList: string[]; | ||
| } | ||
| export interface MessageTemplateData { | ||
| /** | ||
| * 项目名称 | ||
| */ | ||
| project: string; | ||
| } | ||
| export interface PopoResponse<T> { | ||
| data: T; | ||
| errcode: number; | ||
| errmsg: string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import type { PlatformData, AssetMapping, PublishType } from './types'; | ||
| export declare const platforms: PlatformData[]; | ||
| export declare const mappings: Record<PublishType, AssetMapping[]>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mappings = exports.platforms = void 0; | ||
| exports.platforms = [ | ||
| { | ||
| name: 'dev', | ||
| display: '联调平台', | ||
| bucketName: 'lowcode-static', | ||
| endpoint: 'minio-api.codewave-dev.163yun.com', | ||
| }, | ||
| { | ||
| name: 'test', | ||
| display: '测试平台', | ||
| bucketName: 'lowcode-static', | ||
| endpoint: 'minio-api.codewave-test.163yun.com', | ||
| }, | ||
| ]; | ||
| exports.mappings = { | ||
| ide: [ | ||
| { | ||
| from: 'dist-helper', | ||
| to: (version, branch = '') => branch.length > 0 | ||
| ? `packages/branchs/${branch}/@lcap/helper@${version}/dist-helper/` | ||
| : `packages/@lcap/helper@${version}/dist-helper/`, | ||
| }, | ||
| { | ||
| from: 'dist-mdd-ide', | ||
| to: (version, branch = '') => branch.length > 0 | ||
| ? `packages/branchs/${branch}/@lcap/mdd-ide@${version}/dist-mdd-ide/` | ||
| : `packages/@lcap/mdd-ide@${version}/dist-mdd-ide/`, | ||
| }, | ||
| ], | ||
| vue3: [ | ||
| { | ||
| from: 'dist/vue.global.prod.js', | ||
| to: (version, branch = '') => 'packages/vue@3/dist/vue.min.js', | ||
| }, | ||
| ], | ||
| sandbox: [ | ||
| { | ||
| from: 'www', | ||
| to: (version, branch = '') => branch.length > 0 | ||
| ? `packages/branchs/${branch}/sandbox@${version}/` | ||
| : `packages/sandbox@${version}/`, | ||
| }, | ||
| ], | ||
| }; |
| export * from './types'; | ||
| export * from './publish'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./types"), exports); | ||
| tslib_1.__exportStar(require("./publish"), exports); |
| import type { CommandOptions } from './types'; | ||
| export declare function publish(root: string, opt: CommandOptions): Promise<void>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.publish = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const path_1 = tslib_1.__importDefault(require("path")); | ||
| const promises_1 = require("fs/promises"); | ||
| const recursive_readdir_1 = tslib_1.__importDefault(require("recursive-readdir")); | ||
| const client_1 = require("../client"); | ||
| const secret_1 = require("../../utils/secret"); | ||
| const project_1 = require("../../utils/project"); | ||
| const constant_1 = require("./constant"); | ||
| const log_1 = require("../../utils/log"); | ||
| const string_1 = require("../../utils/string"); | ||
| async function getOptions(root, opt) { | ||
| if (!opt.token && !opt.tokenFile) { | ||
| throw new Error(`请输入${log_1.color.red('发布密钥')}`); | ||
| } | ||
| const tokenData = await (0, secret_1.getSecretByOption)(root, opt); | ||
| const platformData = constant_1.platforms.find((item) => item.name === opt.platform); | ||
| if (!platformData) { | ||
| throw new Error(`发布平台输入错误,只能输入 ` + | ||
| `${log_1.color.red('dev')}(联调平台)或者 ` + | ||
| `${log_1.color.red('test')}(测试平台)`); | ||
| } | ||
| const version = await (0, project_1.getVersion)(root); | ||
| if (!version) { | ||
| throw new Error(`错误的版本格式,请确定在 ${log_1.color.red('package.json')} ` + | ||
| `文件的 ${log_1.color.red('version')} 字段格式正确`); | ||
| } | ||
| if (opt.mode === 'independent' && !opt.branch) { | ||
| throw new Error(`独立发布模式时,分支名称不能为空`); | ||
| } | ||
| return { | ||
| ...tokenData, | ||
| ...platformData, | ||
| version, | ||
| }; | ||
| } | ||
| function getMetaData(opt) { | ||
| const data = { | ||
| 'Access-Control-Allow-Origin': '*', | ||
| }; | ||
| if (opt.publisher) { | ||
| data.Publisher = opt.publisher; | ||
| } | ||
| if (opt.publishAt) { | ||
| data.PublishAt = opt.publishAt; | ||
| } | ||
| if (opt.branch) { | ||
| data.Branch = opt.branch; | ||
| } | ||
| return data; | ||
| } | ||
| async function publish(root, opt) { | ||
| const options = await getOptions(root, opt); | ||
| const branchName = opt.branch && opt.mode === 'independent' ? (0, string_1.formatBranch)(opt.branch) : undefined; | ||
| log_1.logger.info(`发布任务开始,资源:${log_1.color.yellow(opt.type)},平台:${log_1.color.yellow(options.display)},版本号:${log_1.color.yellow(options.version)}${branchName | ||
| ? `,分支名:${log_1.color.yellow(opt.branch)}(格式化为:"${log_1.color.yellow(branchName)}")` | ||
| : ''}`); | ||
| const client = new client_1.LcapClient({ | ||
| endPoint: options.endpoint, | ||
| bucketName: options.bucketName, | ||
| accessKey: options.access, | ||
| secretKey: options.secret, | ||
| port: 80, | ||
| useSSL: false, | ||
| }); | ||
| const mappeds = constant_1.mappings[opt.type].map(({ from, to }) => ({ | ||
| from, | ||
| to: to(options.version, branchName), | ||
| })); | ||
| log_1.logger.info('服务器连接成功,开始读取硬盘文件...'); | ||
| const dirFiles = await Promise.all(mappeds.map(async ({ from, to }) => { | ||
| const baseDir = path_1.default.join(root, from); | ||
| const baseDirStat = await (0, promises_1.stat)(baseDir).catch(() => void 0); | ||
| if (!baseDirStat) { | ||
| return []; | ||
| } | ||
| if (baseDirStat.isDirectory()) { | ||
| return (0, recursive_readdir_1.default)(baseDir) | ||
| .then((allFiles) => { | ||
| return Promise.all(allFiles.map(async (item) => ({ | ||
| from: item, | ||
| content: await (0, promises_1.readFile)(item), | ||
| to: path_1.default.join(to, path_1.default.relative(baseDir, item)), | ||
| }))); | ||
| }) | ||
| .catch(() => []); | ||
| } | ||
| else { | ||
| return [ | ||
| { | ||
| from: baseDir, | ||
| content: await (0, promises_1.readFile)(baseDir), | ||
| // 输入是文件时,输出也一定是文件 | ||
| to, | ||
| } | ||
| ]; | ||
| } | ||
| })); | ||
| const files = dirFiles.reduce((ans, item) => (ans.push(...item), ans), []); | ||
| const size = files.reduce((ans, item) => ans + item.content.byteLength, 0); | ||
| const metaData = getMetaData(opt); | ||
| log_1.logger.info(`硬盘文件读取完成,共 ${log_1.color.yellow(files.length)} 个文件,` + | ||
| `${log_1.color.yellow((size / 1024 / 1024).toFixed(2))} MB`); | ||
| log_1.logger.info(`开始删除旧文件...`); | ||
| await Promise.all(dirFiles.map(async (dir, index) => { | ||
| if (dir.length === 0) { | ||
| return; | ||
| } | ||
| const list = await client.listFiles(mappeds[index].to); | ||
| await client.deleteFiles(...list); | ||
| })); | ||
| log_1.logger.info(`开始上传文件...`); | ||
| await client.putFiles(files, metaData, (file, index) => { | ||
| log_1.spinner.text = | ||
| `正在上传 ${log_1.color.yellow(path_1.default.relative(root, file))},` + | ||
| `总进度 ${log_1.color.green(index)} / ` + | ||
| `${log_1.color.red(files.length)}...`; | ||
| if (index === 1) { | ||
| log_1.spinner.start(); | ||
| } | ||
| }); | ||
| log_1.spinner.stop(); | ||
| log_1.spinner.clear(); | ||
| log_1.logger.info(`发布任务完成!`); | ||
| } | ||
| exports.publish = publish; |
| import type { TokenData } from '../../utils'; | ||
| /** | ||
| * 平台数据 | ||
| */ | ||
| export interface PlatformData { | ||
| /** | ||
| * 平台名称 | ||
| */ | ||
| name: 'dev' | 'test'; | ||
| /** | ||
| * 平台显示名称 | ||
| */ | ||
| display: string; | ||
| /** | ||
| * 平台链接 | ||
| */ | ||
| endpoint: string; | ||
| /** | ||
| * 资源桶名称 | ||
| */ | ||
| bucketName: string; | ||
| } | ||
| /** 密钥数据 */ | ||
| export interface SecretData { | ||
| access: string; | ||
| secret: string; | ||
| } | ||
| /** 资源映射 */ | ||
| export interface AssetMapping { | ||
| /** 本地文件夹 */ | ||
| from: string; | ||
| /** | ||
| * 线上文件夹 | ||
| * | ||
| * @description 线上路径需要和版本号以及分支名称拼接 | ||
| */ | ||
| to(version: string, branch?: string): string; | ||
| } | ||
| export type PublishType = 'ide' | 'vue3' | 'sandbox'; | ||
| export interface CommandOptions extends TokenData { | ||
| /** 发布平台 */ | ||
| platform: PlatformData['name']; | ||
| /** 发布资源 */ | ||
| type: PublishType; | ||
| /** 发布模式 */ | ||
| mode: 'normal' | 'independent'; | ||
| /** 发布人账号 */ | ||
| publisher?: string; | ||
| /** | ||
| * 发布时间 | ||
| * | ||
| * @description ISO 8601 format | ||
| */ | ||
| publishAt?: string; | ||
| /** 当前分支名称 */ | ||
| branch?: string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| /// <reference types="node" /> | ||
| import { ClientOptions } from 'minio'; | ||
| /** 资源数据 */ | ||
| export interface AssetData { | ||
| /** 本地文件夹 */ | ||
| from: string; | ||
| /** 线上文件夹 */ | ||
| to: string; | ||
| /** 资源数据 */ | ||
| content: Buffer; | ||
| } | ||
| export type LcapClientOptions = ClientOptions & { | ||
| bucketName: string; | ||
| }; | ||
| /** | ||
| * 操作进度 | ||
| * | ||
| * @description 当前操作的进度 | ||
| * @param {string} file 当前文件 | ||
| * @param {number} fileIndex 当前文件是输入文件列表的第几个 | ||
| * @param {number} [progress] 当前文件的进度 | ||
| */ | ||
| export type FileProgress = (file: string, fileIndex: number) => void; | ||
| export declare class LcapClient { | ||
| /** 桶名称 */ | ||
| private bucketName; | ||
| /** 原始客户端 */ | ||
| private client; | ||
| constructor({ bucketName, ...restOpt }: LcapClientOptions); | ||
| listFiles(basePath: string): Promise<string[]>; | ||
| readFile(fileName: string): Promise<Buffer>; | ||
| putFiles(files: AssetData[], metaData?: Record<string, string>, progress?: FileProgress): Promise<void>; | ||
| deleteFiles(...fileNames: string[]): Promise<void>; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.LcapClient = void 0; | ||
| const mime_1 = require("mime"); | ||
| const minio_1 = require("minio"); | ||
| const utils_1 = require("../../utils"); | ||
| class LcapClient { | ||
| /** 桶名称 */ | ||
| bucketName; | ||
| /** 原始客户端 */ | ||
| client; | ||
| constructor({ bucketName, ...restOpt }) { | ||
| this.client = new minio_1.Client(restOpt); | ||
| this.bucketName = bucketName; | ||
| } | ||
| listFiles(basePath) { | ||
| const files = []; | ||
| return new Promise((resolve, reject) => { | ||
| this.client | ||
| .listObjects(this.bucketName, basePath, true) | ||
| .on('data', (item) => item.name && files.push(item.name)) | ||
| .on('end', () => resolve(files)) | ||
| .on('error', (err) => reject(err)); | ||
| }); | ||
| } | ||
| readFile(fileName) { | ||
| return new Promise((resolve, reject) => { | ||
| this.client.getObject(this.bucketName, fileName, (error, read) => { | ||
| if (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| let buf = new Uint8Array([]); | ||
| read | ||
| .on('data', (chunk) => buf = (0, utils_1.mergeUint8Array)(buf, chunk)) | ||
| .on('end', () => resolve(Buffer.from(buf))) | ||
| .on('error', (err) => reject(err)); | ||
| }); | ||
| }); | ||
| } | ||
| async putFiles(files, metaData, progress) { | ||
| // 这里需要等待日志打印 | ||
| await (0, utils_1.delay)(100); | ||
| for (let i = 0; i < files.length; i++) { | ||
| const { from, to, content } = files[i]; | ||
| progress?.(from, i + 1); | ||
| await this.client.putObject(this.bucketName, to, content, { | ||
| 'Content-Type': (0, mime_1.getType)(from), | ||
| ...metaData, | ||
| }); | ||
| } | ||
| } | ||
| deleteFiles(...fileNames) { | ||
| return this.client.removeObjects(this.bucketName, fileNames); | ||
| } | ||
| } | ||
| exports.LcapClient = LcapClient; |
| export * from './client'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./client"), exports); |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const publish_1 = require("./api/publish"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('publish', '发布前端资源', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('platform', { | ||
| type: 'string', | ||
| describe: '发布平台', | ||
| choices: ['dev', 'test'], | ||
| default: 'dev', | ||
| }) | ||
| .option('type', { | ||
| type: 'string', | ||
| describe: '发布资源类型', | ||
| choices: ['ide', 'vue3', 'sandbox'], | ||
| default: 'ide', | ||
| }) | ||
| .option('mode', { | ||
| type: 'string', | ||
| describe: '发布模式,独立发布模式时将会按照分支名称独立发布', | ||
| choices: ['normal', 'independent'], | ||
| default: 'normal', | ||
| }) | ||
| .option('publisher', { | ||
| alias: 'p', | ||
| type: 'string', | ||
| describe: '发布人账号,它将会附加到资源的 Headers 中', | ||
| }) | ||
| .option('branch', { | ||
| type: 'string', | ||
| describe: '当前发布分支名称,它将会附加到资源的 Headers 中', | ||
| }) | ||
| .option('publishAt', { | ||
| alias: 't', | ||
| type: 'string', | ||
| describe: '发布时间,它将会附加到资源的 Headers 中', | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, publish_1.publish)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; |
| export { registerCommand } from './command'; | ||
| export * from './api'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); | ||
| tslib_1.__exportStar(require("./api"), exports); |
| import { CommandOptions } from './types'; | ||
| export declare function release(root: string, opt: CommandOptions): Promise<void>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.release = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const path_1 = tslib_1.__importDefault(require("path")); | ||
| const recursive_readdir_1 = tslib_1.__importDefault(require("recursive-readdir")); | ||
| const promises_1 = require("fs/promises"); | ||
| const gitlab_1 = require("../utils/gitlab"); | ||
| const utils_1 = require("../utils"); | ||
| const constant_1 = require("./constant"); | ||
| async function autoMr(root, gitlab, data) { | ||
| const version = await (0, utils_1.getVersion)(root); | ||
| utils_1.logger.info(`当前物料 ${utils_1.color.yellow(data.kind.toUpperCase())},版本 ${utils_1.color.yellow(version)}`); | ||
| const basePathInRemote = constant_1.AssetPath.ide(version); | ||
| utils_1.logger.info(`检索远程仓库代码...`); | ||
| const filesInRemote = await gitlab.listFiles(basePathInRemote, constant_1.AssetRef); | ||
| utils_1.logger.info(`读取本地文件...`); | ||
| const filesInDisk = await (0, recursive_readdir_1.default)(data.distDir); | ||
| const filesData = await Promise.all((filesInDisk).map(async (file) => { | ||
| const diskPath = path_1.default.join(root, file); | ||
| const remotePath = path_1.default.join(basePathInRemote, path_1.default.relative(data.distDir, file)); | ||
| const fileBuffer = await (0, promises_1.readFile)(diskPath); | ||
| const size = fileBuffer.byteLength; | ||
| const content = fileBuffer.toString('base64'); | ||
| return { | ||
| diskPath, | ||
| remotePath, | ||
| size, | ||
| content, | ||
| }; | ||
| })); | ||
| if (filesData.length === 0) { | ||
| utils_1.logger.info(`未发现本地数据,进程退出。`); | ||
| if (data.output) { | ||
| utils_1.logger.info(`MR 结果写入上下文...`); | ||
| await (0, utils_1.writeContext)(root, data.output, { mr_url: 'NONE' }); | ||
| } | ||
| return; | ||
| } | ||
| utils_1.logger.info(`正在准备 Diff 数据...`); | ||
| const filesDiff = await gitlab.getFilesDiff(filesInRemote, filesData); | ||
| utils_1.logger.info(`开始创建分支...`); | ||
| const newBranchName = `auto-release/${data.kind}/${version}/${Date.now()}`; | ||
| const branchData = await gitlab.createBranch({ | ||
| branch: newBranchName, | ||
| ref: constant_1.AssetRef, | ||
| }); | ||
| utils_1.logger.info(`分支创建完成,新分支名为 ${utils_1.color.yellow(newBranchName)},分支链接为:${branchData.web_url}`); | ||
| utils_1.logger.info(`开始提交代码...`); | ||
| const commitData = await gitlab.createCommitWithFiles({ | ||
| commit_message: `auto-release: 🔧 自动提交 ${version} 版本 ${data.kind.toUpperCase()} 物料`, | ||
| branch: newBranchName, | ||
| actions: filesDiff, | ||
| author_name: data.authorName, | ||
| author_email: data.authorEmail, | ||
| force: false, | ||
| }); | ||
| utils_1.logger.info(`代码提交成功,Commit 链接为:${utils_1.color.blackBright(commitData.web_url)}`); | ||
| utils_1.logger.info(`开始创建 MR...`); | ||
| const params = { | ||
| version, | ||
| time: Date.now(), | ||
| kind: data.kind, | ||
| }; | ||
| const mergeRequestData = await gitlab.createMrWithBranch({ | ||
| target_branch: constant_1.AssetRef, | ||
| source_branch: newBranchName, | ||
| title: (0, utils_1.formatMessageByParams)(data.mrTitle, params), | ||
| description: (0, utils_1.formatMessageByParams)(data.mrMessage, params), | ||
| squash: true, | ||
| remove_source_branch: true, | ||
| labels: 'auto-release' | ||
| }); | ||
| utils_1.logger.info(`MR 创建成功,MR 链接为:${utils_1.color.blackBright(mergeRequestData.web_url)}`); | ||
| if (data.output) { | ||
| utils_1.logger.info(`MR 结果写入上下文...`); | ||
| await (0, utils_1.writeContext)(root, data.output, { | ||
| mr_url: mergeRequestData.web_url, | ||
| }); | ||
| } | ||
| utils_1.logger.info(`代码自动合并结束!`); | ||
| } | ||
| async function release(root, opt) { | ||
| const tokenData = await (0, utils_1.getSecretByOption)(root, opt); | ||
| const gitlab = new gitlab_1.Gitlab(constant_1.AssetsReleaseId, tokenData.tokenId); | ||
| return autoMr(root, gitlab, opt); | ||
| } | ||
| exports.release = release; |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const api_1 = require("./api"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('release', '前端物料发布', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('kind', { | ||
| type: 'string', | ||
| describe: '发布物料种类', | ||
| choices: ['ide'], | ||
| default: 'ide', | ||
| }) | ||
| .option('distDir', { | ||
| type: 'string', | ||
| describe: '物料文件目录', | ||
| demandOption: true, | ||
| }) | ||
| .option('mrTitle', { | ||
| type: 'string', | ||
| describe: 'MR 标题', | ||
| default: 'auto-release/[kind]-[version]-[time]', | ||
| }) | ||
| .option('mrMessage', { | ||
| type: 'string', | ||
| describe: 'MR 描述', | ||
| default: '', | ||
| }) | ||
| .option('authorEmail', { | ||
| type: 'string', | ||
| describe: '作者邮箱', | ||
| }) | ||
| .option('authorName', { | ||
| type: 'string', | ||
| describe: '作者姓名', | ||
| }) | ||
| .option('output', { | ||
| type: 'string', | ||
| describe: '结果储存文件', | ||
| }) | ||
| .check((argv) => { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| }); | ||
| }, (argv) => { | ||
| return (0, api_1.release)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; |
| import { ReleaseKind } from './types'; | ||
| /** 物料仓库编号 */ | ||
| export declare const AssetsReleaseId = "vusion/lcap-assets"; | ||
| /** | ||
| * 合入分支 | ||
| */ | ||
| export declare const AssetRef = "master"; | ||
| /** | ||
| * 物料出口 | ||
| */ | ||
| export declare const AssetPath: Record<ReleaseKind, (version: string) => string>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AssetPath = exports.AssetRef = exports.AssetsReleaseId = void 0; | ||
| /** 物料仓库编号 */ | ||
| exports.AssetsReleaseId = 'vusion/lcap-assets'; | ||
| /** | ||
| * 合入分支 | ||
| */ | ||
| exports.AssetRef = 'master'; | ||
| /** | ||
| * 物料出口 | ||
| */ | ||
| exports.AssetPath = { | ||
| ide: (version) => `data/packages/@lcap/mdd-ide@${version}/dist-mdd-ide`, | ||
| }; |
| export * from './command'; | ||
| export * from './types'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./command"), exports); | ||
| tslib_1.__exportStar(require("./types"), exports); |
| import type { TokenData } from '../utils'; | ||
| /** 物料种类 */ | ||
| export type ReleaseKind = 'ide'; | ||
| /** | ||
| * 项目访问密钥 | ||
| * | ||
| * @link https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html | ||
| */ | ||
| export interface GitlabTokenData { | ||
| tokenId: string; | ||
| } | ||
| /** | ||
| * 自动创建合并请求 | ||
| */ | ||
| export interface AutoMrData { | ||
| /** | ||
| * 发布物料种类 | ||
| */ | ||
| kind: ReleaseKind; | ||
| /** | ||
| * 提交文件目录 | ||
| * | ||
| * @description 文件夹目录 | ||
| */ | ||
| distDir: string; | ||
| /** | ||
| * MR 标题 | ||
| * | ||
| * @description 允许使用的参数:[time]、[version] | ||
| */ | ||
| mrTitle: string; | ||
| /** | ||
| * MR 描述 | ||
| * | ||
| * @description 允许使用的参数:[time]、[version] | ||
| */ | ||
| mrMessage: string; | ||
| /** | ||
| * 作者邮箱 | ||
| */ | ||
| authorEmail: string; | ||
| /** | ||
| * 作者姓名 | ||
| */ | ||
| authorName: string; | ||
| /** | ||
| * 临时文件 | ||
| */ | ||
| output: string; | ||
| } | ||
| export type CommandOptions = TokenData & AutoMrData; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import Yargs from 'yargs'; | ||
| export declare function registerCommand(yargs: Yargs.Argv<any>): void; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const trigger_1 = require("./trigger"); | ||
| function registerCommand(yargs) { | ||
| yargs.command('trigger', '前端事件触发器', (yargs) => { | ||
| yargs | ||
| .options(utils_1.tokenOptions) | ||
| .option('platform', { | ||
| type: 'string', | ||
| describe: '平台数据', | ||
| choices: ['dev', 'test'], | ||
| default: 'dev', | ||
| }) | ||
| .option('kind', { | ||
| type: 'string', | ||
| describe: '事件类型', | ||
| choices: ['merge_request', 'push', 'publish'], | ||
| }) | ||
| .option('id', { | ||
| type: 'string', | ||
| describe: 'MR 编号', | ||
| }) | ||
| .option('userEmail', { | ||
| type: 'string', | ||
| describe: '用户邮箱', | ||
| }) | ||
| .option('lastCommitSha', { | ||
| type: 'string', | ||
| describe: '最后一次提交的 HASH', | ||
| }) | ||
| .option('branch', { | ||
| type: 'string', | ||
| describe: '分支名称', | ||
| }) | ||
| .option('targetBranch', { | ||
| type: 'string', | ||
| describe: '合并目标分支名称', | ||
| }) | ||
| .option('output', { | ||
| type: 'string', | ||
| describe: '输出数据保存文件', | ||
| }) | ||
| .option('clear', { | ||
| type: 'boolean', | ||
| describe: '清除所有缓存', | ||
| }) | ||
| .check((argv) => { | ||
| if (argv.clear) { | ||
| return (0, utils_1.tokenCheck)(argv); | ||
| } | ||
| else { | ||
| return (0, utils_1.tokenCheck)(argv) && (0, trigger_1.check)(argv); | ||
| } | ||
| }); | ||
| }, (argv) => { | ||
| return (0, trigger_1.trigger)(process.cwd(), argv).catch((err) => { | ||
| utils_1.logger.error(err.message); | ||
| process.exit(1); | ||
| }); | ||
| }); | ||
| } | ||
| exports.registerCommand = registerCommand; |
| export { registerCommand } from './command'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.registerCommand = void 0; | ||
| var command_1 = require("./command"); | ||
| Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_1.registerCommand; } }); |
| import type { BaseData, PipelineStore } from './types'; | ||
| export declare class Store { | ||
| /** 缓存文件链接 */ | ||
| static URL: string; | ||
| private readonly root; | ||
| private _client?; | ||
| data: PipelineStore; | ||
| constructor(root: string); | ||
| read(opt: BaseData): Promise<PipelineStore>; | ||
| update(): Promise<void>; | ||
| clear(): Promise<void>; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Store = void 0; | ||
| const client_1 = require("../publish/client"); | ||
| const utils_1 = require("../utils"); | ||
| const constant_1 = require("../publish/api/constant"); | ||
| const initData = { | ||
| dev: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| test: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| }; | ||
| /** 虚拟文件路径 */ | ||
| const fileViPath = 'packages/store.json'; | ||
| /** 测试平台数据 */ | ||
| const testPlatform = constant_1.platforms.find((item) => item.name === 'test'); | ||
| class Store { | ||
| /** 缓存文件链接 */ | ||
| static URL = `https://${testPlatform.endpoint}/${testPlatform.bucketName}/${fileViPath}`; | ||
| root; | ||
| _client; | ||
| data = { ...initData }; | ||
| constructor(root) { | ||
| this.root = root; | ||
| } | ||
| async read(opt) { | ||
| const token = await (0, utils_1.getSecretByOption)(this.root, opt); | ||
| const client = new client_1.LcapClient({ | ||
| bucketName: testPlatform.bucketName, | ||
| endPoint: testPlatform.endpoint, | ||
| accessKey: token.access, | ||
| secretKey: token.secret, | ||
| }); | ||
| const fileInStore = await client.readFile(fileViPath).catch(() => void 0); | ||
| const data = fileInStore ? JSON.parse(fileInStore.toString('utf-8')) : { | ||
| dev: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| test: { | ||
| mr: [], | ||
| lastPublish: [], | ||
| }, | ||
| }; | ||
| this.data = data; | ||
| this._client = client; | ||
| return this.data; | ||
| } | ||
| async update() { | ||
| if (!this._client) { | ||
| throw new Error('请先初始化 client'); | ||
| } | ||
| return this._client.putFiles([ | ||
| { | ||
| from: fileViPath, | ||
| to: fileViPath, | ||
| content: Buffer.from(JSON.stringify(this.data)), | ||
| } | ||
| ]); | ||
| } | ||
| clear() { | ||
| if (!this._client) { | ||
| throw new Error('请先初始化 client'); | ||
| } | ||
| this.data = { ...initData }; | ||
| return this.update(); | ||
| } | ||
| } | ||
| exports.Store = Store; |
| import type { CommandOptions } from './types'; | ||
| export declare function check(opt: CommandOptions): boolean; | ||
| export declare function trigger(root: string, opt: CommandOptions): Promise<void>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.trigger = exports.check = void 0; | ||
| const utils_1 = require("../utils"); | ||
| const store_1 = require("./store"); | ||
| function check(opt) { | ||
| const shouldFillProps = []; | ||
| if (opt.kind === 'merge_request') { | ||
| shouldFillProps.push('id', 'userEmail', 'lastCommitSha', 'branch', 'targetBranch'); | ||
| } | ||
| else if (opt.kind === 'publish') { | ||
| shouldFillProps.push('branch', 'lastCommitSha'); | ||
| } | ||
| else if (opt.kind === 'push') { | ||
| shouldFillProps.push('branch', 'lastCommitSha'); | ||
| } | ||
| else { | ||
| throw new Error(`未知的触发事件: ${opt.kind}`); | ||
| } | ||
| const notFilledProps = shouldFillProps.filter((key) => { | ||
| return !(key in opt); | ||
| }); | ||
| if (notFilledProps.length > 0) { | ||
| throw new Error(`事件为 ${opt.kind},缺少下列必填项: ${notFilledProps.join(', ')}`); | ||
| } | ||
| return true; | ||
| } | ||
| exports.check = check; | ||
| /** | ||
| * MR 事件 | ||
| * | ||
| * @description 只记录数据,无输出 | ||
| */ | ||
| async function triggerMergeRequest(root, opt) { | ||
| const mrData = { | ||
| id: opt.id, | ||
| userEmail: opt.userEmail, | ||
| lastCommitSha: opt.lastCommitSha, | ||
| branch: opt.branch, | ||
| targetBranch: opt.targetBranch, | ||
| }; | ||
| utils_1.logger.info(`此次记录数据为: ${JSON.stringify(mrData, null, 2)}`); | ||
| const store = new store_1.Store(root); | ||
| const data = await store.read(opt); | ||
| const platformData = data[opt.platform]; | ||
| if (platformData.mr.some((item) => item.id === mrData.id)) { | ||
| utils_1.logger.info(`有重复数据,退出流程,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| return; | ||
| } | ||
| utils_1.logger.info('没有重复数据,添加数据'); | ||
| platformData.mr.push(mrData); | ||
| await store.update(); | ||
| utils_1.logger.info(`数据更新完成,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| /** | ||
| * 发布事件 | ||
| * | ||
| * @description 在相同版本号、分支、平台相同的情况下,拉出新旧 commit 之间的所有提交人,并更新发布记录 | ||
| * @return {Promise<string>} 记录中所有人的邮箱,用逗号分隔 | ||
| */ | ||
| async function triggerPublish(root, opt) { | ||
| const store = new store_1.Store(root); | ||
| const data = await store.read(opt); | ||
| const platformData = data[opt.platform].lastPublish ?? []; | ||
| const version = await (0, utils_1.getVersion)(root); | ||
| const lastPublish = platformData.find((item) => item.versionName === version); | ||
| let gitLog = ''; | ||
| let message = ''; | ||
| if (lastPublish) { | ||
| utils_1.logger.info(`发布在 ${opt.branch} 分支的 ${version} 版本上次发布的提交是 ${lastPublish.lastCommitSha},本次提交是 ${opt.lastCommitSha}`); | ||
| gitLog = await (0, utils_1.runCommand)(`git log --pretty=format:%ae ${lastPublish.lastCommitSha}...${opt.lastCommitSha} | sort | uniq`) | ||
| .catch((e) => { | ||
| utils_1.logger.warn('未找到提交人,原始错误信息:', e.toString()); | ||
| return ''; | ||
| }); | ||
| lastPublish.lastCommitSha = opt.lastCommitSha; | ||
| lastPublish.branch = opt.branch; | ||
| } | ||
| else { | ||
| utils_1.logger.info(`首次发布在 ${opt.branch} 分支的 ${version} 版本`); | ||
| platformData.push({ | ||
| branch: opt.branch, | ||
| versionName: version, | ||
| lastCommitSha: opt.lastCommitSha, | ||
| }); | ||
| if (!data[opt.platform].lastPublish) { | ||
| data[opt.platform].lastPublish = platformData; | ||
| } | ||
| gitLog = await (0, utils_1.runCommand)(`git show -s --format='%ae' ${opt.lastCommitSha}`) | ||
| .catch((e) => { | ||
| utils_1.logger.warn('未找到提交人,原始错误信息:', e.toString()); | ||
| return ''; | ||
| }); | ||
| } | ||
| const emailArray = gitLog | ||
| .trim() | ||
| .split('\n') | ||
| .map((item) => item.trim()) | ||
| .filter((item) => item.length > 0) | ||
| .map((item) => `@${item}`); | ||
| const emails = Array.from(new Set(emailArray)); | ||
| if (emails.length === 0) { | ||
| message = `@所有人 PUSH 代码自动更新 ${version} 版本IDE\n🧩分支: ${opt.branch}`; | ||
| } | ||
| else { | ||
| message = `@所有人 PUSH 代码自动更新 ${version} 版本IDE\n🧩分支: ${opt.branch}\n🔧此次发布包含下列同事的提交: ${emails.join(',')}`; | ||
| } | ||
| await (0, utils_1.writeContext)(root, opt.output, { message }); | ||
| await store.update(); | ||
| utils_1.logger.info(`数据更新完成,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| /** | ||
| * 推送事件 | ||
| * | ||
| * @description 在推送分支比较当前所有 MR 记录下的数据,若是其内部目标分支为当前,并且其 commit 已经被当前分支包含,则表示此分支已经被合并 | ||
| * @description 若是 MR 记录已经被合并,则此记录会被删除 | ||
| * @return {Promise<[string, string, string]>} [MR 的编号, 被合并的分支名称, 提交分人的邮箱] | ||
| */ | ||
| async function triggerPush(root, opt) { | ||
| const store = new store_1.Store(root); | ||
| const data = await store.read(opt); | ||
| const platformData = data[opt.platform].mr ?? []; | ||
| if (platformData.length === 0) { | ||
| utils_1.logger.info('没有 MR 数据记录,退出流程'); | ||
| return; | ||
| } | ||
| let deleteIndex = -1; | ||
| for (let i = 0; i < platformData.length; i++) { | ||
| const data = platformData[i]; | ||
| const containBranch = await (0, utils_1.runCommand)(`git branch --contains ${data.lastCommitSha} ${opt.branch}`); | ||
| const isContainCommit = containBranch.trim() === opt.branch; | ||
| if (isContainCommit) { | ||
| utils_1.logger.info(`下述请求被包含在当前 PUSH 中: ${JSON.stringify(data, null, 2)}`); | ||
| deleteIndex = i; | ||
| break; | ||
| } | ||
| } | ||
| if (deleteIndex === -1) { | ||
| utils_1.logger.info('数据库中的 MR 请求均并未被包含在此次 PUSH 中,退出流程'); | ||
| return; | ||
| } | ||
| const deleteMrData = platformData[deleteIndex]; | ||
| platformData.splice(deleteIndex, 1); | ||
| await store.update(); | ||
| await (0, utils_1.writeContext)(root, opt.output, { | ||
| mr_id: deleteMrData.id, | ||
| mr_user: deleteMrData.userEmail, | ||
| source_branch: deleteMrData.branch, | ||
| target_branch: deleteMrData.targetBranch, | ||
| }); | ||
| utils_1.logger.info(`数据更新完成,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| /** 清空缓存 */ | ||
| async function clearTrigger(root, opt) { | ||
| const store = new store_1.Store(root); | ||
| await store.read(opt); | ||
| await store.clear(); | ||
| utils_1.logger.info(`清除缓存,可以在此链接访问数据:${store_1.Store.URL}`); | ||
| } | ||
| async function trigger(root, opt) { | ||
| if (opt.clear) { | ||
| return clearTrigger(root, opt); | ||
| } | ||
| else if (opt.kind === 'merge_request') { | ||
| return triggerMergeRequest(root, opt); | ||
| } | ||
| else if (opt.kind === 'publish') { | ||
| return triggerPublish(root, opt); | ||
| } | ||
| else { | ||
| return triggerPush(root, opt); | ||
| } | ||
| } | ||
| exports.trigger = trigger; |
| import type { TokenData } from '../utils/secret'; | ||
| export type Platform = 'dev' | 'test'; | ||
| export interface BaseData extends TokenData { | ||
| /** 当前平台 */ | ||
| platform: Platform; | ||
| /** | ||
| * 触发事件类别 | ||
| */ | ||
| kind: string; | ||
| /** 临时文件 */ | ||
| output: string; | ||
| /** 清除缓存 */ | ||
| clear?: boolean; | ||
| } | ||
| export interface MergeRequestData { | ||
| /** MR 编号 */ | ||
| id: string; | ||
| /** 用户邮箱 */ | ||
| userEmail: string; | ||
| /** 最后一次提交的 HASH */ | ||
| lastCommitSha: string; | ||
| /** 分支名称 */ | ||
| branch: string; | ||
| /** 合并目标分支名称 */ | ||
| targetBranch: string; | ||
| } | ||
| export interface PublishData { | ||
| /** 发布版本 */ | ||
| versionName: string; | ||
| /** 发布分支 */ | ||
| branch: string; | ||
| /** 最后一次提交的 HASH */ | ||
| lastCommitSha: string; | ||
| } | ||
| export interface PushData { | ||
| /** 当前分支 */ | ||
| branch: string; | ||
| /** 最后一次提交的 HASH */ | ||
| lastCommitSha: string; | ||
| } | ||
| export interface PipelineStorePlatform { | ||
| /** 合并请求数据 */ | ||
| mr: MergeRequestData[]; | ||
| /** 发布数据 */ | ||
| lastPublish: PublishData[]; | ||
| } | ||
| export type PipelineStore = Record<Platform, PipelineStorePlatform>; | ||
| export type CommandOptions = ({ | ||
| kind: 'merge_request'; | ||
| } & MergeRequestData & BaseData) | ({ | ||
| kind: 'publish'; | ||
| } & PublishData & BaseData) | ({ | ||
| kind: 'push'; | ||
| } & PushData & BaseData); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| export declare function mergeEmail(messages: [string, string][]): string; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mergeEmail = void 0; | ||
| function mergeEmail(messages) { | ||
| const map = new Map(); | ||
| for (const [email, message] of messages) { | ||
| if (!map.has(email)) { | ||
| map.set(email, []); | ||
| } | ||
| map.get(email).push(message); | ||
| } | ||
| let lines = []; | ||
| for (const [email, messages] of map.entries()) { | ||
| lines.push(`👉${email}`); | ||
| messages.forEach((item) => lines.push(` | ${item}`)); | ||
| } | ||
| return lines.join('\n'); | ||
| } | ||
| exports.mergeEmail = mergeEmail; |
| /** 合并两个 Unit8Array */ | ||
| export declare function mergeUint8Array(arr1: Uint8Array, arr2: Uint8Array): Uint8Array; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mergeUint8Array = void 0; | ||
| /** 合并两个 Unit8Array */ | ||
| function mergeUint8Array(arr1, arr2) { | ||
| const mergedArr = new Uint8Array(arr1.length + arr2.length); | ||
| mergedArr.set(arr1); | ||
| mergedArr.set(arr2, arr1.length); | ||
| return mergedArr; | ||
| } | ||
| exports.mergeUint8Array = mergeUint8Array; |
| export declare function runCommand(cmd: string): Promise<string>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.runCommand = void 0; | ||
| const child_process_1 = require("child_process"); | ||
| function runCommand(cmd) { | ||
| return new Promise((resolve, reject) => { | ||
| (0, child_process_1.exec)(cmd, (err, stdout, stderr) => { | ||
| if (err) { | ||
| reject(err); | ||
| return; | ||
| } | ||
| if (stderr) { | ||
| reject(new Error(stderr)); | ||
| return; | ||
| } | ||
| resolve(stdout); | ||
| }); | ||
| }); | ||
| } | ||
| exports.runCommand = runCommand; |
| export declare function writeFile(root: string, file: string, content: string): Promise<void>; | ||
| export declare function writeContext(root: string, file: string, context: object): Promise<void>; | ||
| export declare function readFile(file: string): Promise<string | undefined>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.readFile = exports.writeContext = exports.writeFile = void 0; | ||
| const path_1 = require("path"); | ||
| const promises_1 = require("fs/promises"); | ||
| async function writeFile(root, file, content) { | ||
| const fullPath = (0, path_1.join)(root, file); | ||
| await (0, promises_1.mkdir)((0, path_1.dirname)(fullPath), { recursive: true }); | ||
| await (0, promises_1.writeFile)(fullPath, content); | ||
| } | ||
| exports.writeFile = writeFile; | ||
| async function writeContext(root, file, context) { | ||
| let content = ''; | ||
| for (const [key, value] of Object.entries(context)) { | ||
| content += `${key.toUpperCase()}=${JSON.stringify(value)}\n`; | ||
| } | ||
| return writeFile(root, file, content); | ||
| } | ||
| exports.writeContext = writeContext; | ||
| async function readFile(file) { | ||
| return (0, promises_1.readFile)(file, 'utf-8').catch(() => void 0); | ||
| } | ||
| exports.readFile = readFile; |
| import { CreateCommitData, InputFileData, FileData, FileMetaData, CommitActionData, CreateCommitResponseData, CreateMrData, CreateMrResponseData, CreateBranchData, CreateBranchResponseData } from './types'; | ||
| export declare class Gitlab { | ||
| private id; | ||
| private token; | ||
| constructor(id: string, token: string); | ||
| /** 列出当前路径下的所有文件 */ | ||
| listFiles(basePath?: string, ref?: string): Promise<string[]>; | ||
| /** 获取文件 meta 信息 */ | ||
| getFileMetaData(file: string, ref?: string): Promise<FileMetaData>; | ||
| /** 获取文件信息 */ | ||
| getFileData(file: string, ref?: string): Promise<FileData>; | ||
| /** 对比远端和本地文件 */ | ||
| getFilesDiff(remoteFiles: string[], filesInDisk: InputFileData[]): Promise<CommitActionData[]>; | ||
| /** 从文件创建新分支 */ | ||
| createCommitWithFiles(params: Omit<CreateCommitData, 'id'>): Promise<CreateCommitResponseData>; | ||
| /** 创建新分支 */ | ||
| createBranch(params: Omit<CreateBranchData, 'id'>): Promise<CreateBranchResponseData>; | ||
| /** 从分支创建合并请求 */ | ||
| createMrWithBranch(params: Omit<CreateMrData, 'id'>): Promise<CreateMrResponseData>; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Gitlab = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const axios_1 = tslib_1.__importDefault(require("axios")); | ||
| const constant_1 = require("./constant"); | ||
| const encoding = 'base64'; | ||
| class Gitlab { | ||
| id; | ||
| token; | ||
| constructor(id, token) { | ||
| this.id = id; | ||
| this.token = token; | ||
| } | ||
| /** 列出当前路径下的所有文件 */ | ||
| async listFiles(basePath = '/', ref = 'master') { | ||
| const files = []; | ||
| const perPage = 40; | ||
| const data = { | ||
| id: this.id, | ||
| ref, | ||
| path: basePath, | ||
| pagination: 'keyset', | ||
| per_page: perPage, | ||
| recursive: true, | ||
| }; | ||
| for (let stop = false; !stop;) { | ||
| const { data: result, headers, ...rest } = await (0, axios_1.default)({ | ||
| ...constant_1.Repositories.Tree(this.id), | ||
| params: data, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| files.push(...result | ||
| .filter((item) => item.type === 'blob') | ||
| .map((item) => item.path)); | ||
| const nextPage = Number(headers['x-next-page']); | ||
| if (Number.isNaN(nextPage) || nextPage === 0) { | ||
| stop = true; | ||
| } | ||
| data.page = nextPage; | ||
| } | ||
| return files; | ||
| } | ||
| /** 获取文件 meta 信息 */ | ||
| async getFileMetaData(file, ref = 'master') { | ||
| const { headers } = await (0, axios_1.default)({ | ||
| ...constant_1.Repositories.FileMeta(this.id)(file), | ||
| params: { | ||
| ref, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| const data = { | ||
| blob_id: headers['x-gitlab-blob-id'], | ||
| content_sha256: headers['x-gitlab-content-sha256'], | ||
| encoding: headers['x-gitlab-encoding'], | ||
| ref: headers['x-gitlab-ref'], | ||
| size: Number(headers['x-gitlab-size']), | ||
| commit_id: headers['x-gitlab-commit-id'], | ||
| last_commit_id: headers['x-gitlab-last-commit-id'], | ||
| file_name: headers['x-gitlab-file-name'], | ||
| file_path: headers['x-gitlab-file-path'], | ||
| }; | ||
| return data; | ||
| } | ||
| /** 获取文件信息 */ | ||
| async getFileData(file, ref = 'master') { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.Repositories.File(this.id)(file), | ||
| params: { | ||
| ref, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| /** 对比远端和本地文件 */ | ||
| async getFilesDiff(remoteFiles, filesInDisk) { | ||
| // TODO: 暂不考虑移动的情况 | ||
| // /** 文件名称相同但文件路径不同 */ | ||
| // const filesWithSameName = remoteFiles | ||
| // .map((remoteFile) => { | ||
| // const baseName = path.basename(remoteFile); | ||
| // const diskFileWithSameBaseName = filesInDisk.find((file) => { | ||
| // return path.basename(file.diskPath) === baseName && file.remotePath !== remoteFile; | ||
| // }); | ||
| // if (diskFileWithSameBaseName) { | ||
| // return { | ||
| // remoteFile, | ||
| // diskFile: diskFileWithSameBaseName, | ||
| // baseName: baseName, | ||
| // }; | ||
| // } | ||
| // }) | ||
| // .filter(<T>(input: T): input is NonNullable<T> => Boolean(input)); | ||
| // // 文件名称相同,判断是否只是移动 | ||
| // for (const file of filesWithSameName) { | ||
| // // .. | ||
| // } | ||
| /** 只在远端的文件 */ | ||
| const filesOnlyInRemote = remoteFiles.filter((file) => !filesInDisk.find((remote) => remote.remotePath === file)); | ||
| /** 只在硬盘里的文件 */ | ||
| const filesOnlyInDisk = filesInDisk.filter(({ remotePath: remote }) => !remoteFiles.includes(remote)); | ||
| /** 同时存在两端的文件 */ | ||
| const filesBothIn = filesInDisk.filter(({ remotePath: remote }) => remoteFiles.includes(remote)); | ||
| /** 更新操作数据 */ | ||
| const actions = []; | ||
| // 只存在于远端的文件要删除 | ||
| await Promise.all(filesOnlyInRemote.map(async (file) => { | ||
| const data = await this.getFileMetaData(file); | ||
| actions.push({ | ||
| action: 'delete', | ||
| last_commit_id: data.last_commit_id, | ||
| file_path: file, | ||
| }); | ||
| })); | ||
| // 只存在于硬盘的文件要创建 | ||
| for (const file of filesOnlyInDisk) { | ||
| actions.push({ | ||
| action: 'create', | ||
| file_path: file.remotePath, | ||
| content: file.content, | ||
| encoding, | ||
| }); | ||
| } | ||
| // 同时存在于这两者的需要更新 | ||
| await Promise.all(filesBothIn.map(async (file) => { | ||
| const meta = await this.getFileMetaData(file.remotePath); | ||
| // 长度不同需要更新 | ||
| if (meta.size !== file.size) { | ||
| actions.push({ | ||
| action: 'update', | ||
| encoding, | ||
| content: file.content, | ||
| file_path: file.remotePath, | ||
| last_commit_id: meta.last_commit_id, | ||
| }); | ||
| return; | ||
| } | ||
| const remoteData = await this.getFileData(file.remotePath); | ||
| // 内容不同需要更新 | ||
| // TODO: encoding 不一样怎么办 | ||
| if (remoteData.content !== file.content) { | ||
| actions.push({ | ||
| action: 'update', | ||
| encoding, | ||
| content: file.content, | ||
| file_path: file.remotePath, | ||
| last_commit_id: meta.last_commit_id, | ||
| }); | ||
| } | ||
| })); | ||
| return actions; | ||
| } | ||
| /** 从文件创建新分支 */ | ||
| async createCommitWithFiles(params) { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.Commit.CreateWithAction(this.id), | ||
| data: { | ||
| id: encodeURIComponent(this.id), | ||
| ...params, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| /** 创建新分支 */ | ||
| async createBranch(params) { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.Branch.Create(this.id), | ||
| data: { | ||
| id: encodeURIComponent(this.id), | ||
| ...params, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| /** 从分支创建合并请求 */ | ||
| async createMrWithBranch(params) { | ||
| const { data } = await (0, axios_1.default)({ | ||
| ...constant_1.MR.CreateWithBranch(this.id), | ||
| data: { | ||
| id: this.id, | ||
| ...params, | ||
| }, | ||
| headers: { | ||
| 'PRIVATE-TOKEN': this.token, | ||
| }, | ||
| }); | ||
| return data; | ||
| } | ||
| } | ||
| exports.Gitlab = Gitlab; |
| /** | ||
| * 仓库接口 | ||
| */ | ||
| export declare const Repositories: { | ||
| Tree: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| File: (projectId: string) => (file: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| FileMeta: (projectId: string) => (file: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| /** | ||
| * Branch 分支接口 | ||
| */ | ||
| export declare const Branch: { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| Create: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| /** | ||
| * Commit 提交接口 | ||
| */ | ||
| export declare const Commit: { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| CreateWithAction: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; | ||
| /** | ||
| * MR 提交接口 | ||
| */ | ||
| export declare const MR: { | ||
| /** | ||
| * 创建 MR | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/merge_requests.html#create-mr | ||
| */ | ||
| CreateWithBranch: (projectId: string) => { | ||
| url: string; | ||
| method: string; | ||
| }; | ||
| }; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.MR = exports.Commit = exports.Branch = exports.Repositories = void 0; | ||
| const BaseUrl = 'https://g.hz.netease.com/api/v4'; | ||
| /** | ||
| * 仓库接口 | ||
| */ | ||
| exports.Repositories = { | ||
| Tree: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/tree`, | ||
| method: 'GET', | ||
| }), | ||
| File: (projectId) => (file) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/files/${encodeURIComponent(file)}`, | ||
| method: 'GET', | ||
| }), | ||
| FileMeta: (projectId) => (file) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/files/${encodeURIComponent(file)}`, | ||
| method: 'HEAD', | ||
| }), | ||
| }; | ||
| /** | ||
| * Branch 分支接口 | ||
| */ | ||
| exports.Branch = { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| Create: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/branches`, | ||
| method: 'POST', | ||
| }), | ||
| }; | ||
| /** | ||
| * Commit 提交接口 | ||
| */ | ||
| exports.Commit = { | ||
| /** | ||
| * 从文件创建 commit | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions | ||
| */ | ||
| CreateWithAction: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/repository/commits`, | ||
| method: 'POST', | ||
| }), | ||
| }; | ||
| /** | ||
| * MR 提交接口 | ||
| */ | ||
| exports.MR = { | ||
| /** | ||
| * 创建 MR | ||
| * | ||
| * @link https://docs.gitlab.com/ee/api/merge_requests.html#create-mr | ||
| */ | ||
| CreateWithBranch: (projectId) => ({ | ||
| url: `${BaseUrl}/projects/${encodeURIComponent(projectId)}/merge_requests`, | ||
| method: 'POST', | ||
| }), | ||
| }; |
| export * from './api'; | ||
| export * from './types'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./api"), exports); | ||
| tslib_1.__exportStar(require("./types"), exports); |
| export type FileEncoding = 'text' | 'base64'; | ||
| /** | ||
| * 项目访问密钥 | ||
| * | ||
| * @link https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html | ||
| */ | ||
| export interface GitlabTokenData { | ||
| tokenId: string; | ||
| } | ||
| /** | ||
| * 项目数据 | ||
| */ | ||
| export interface Project { | ||
| /** | ||
| * 项目编号/路径 | ||
| * | ||
| * @description 路径就是指项目的网址,比如项目网址是`https://g.hz.netease.com/vusion/cache-script`,那么这里的 id 就是`vusion%2Fcache-script`,反斜杠要转义。 | ||
| */ | ||
| id: number | string; | ||
| } | ||
| interface CreateCommitBaseData extends Project { | ||
| /** | ||
| * 提交信息 | ||
| */ | ||
| commit_message: string; | ||
| /** | ||
| * 当前提交的行为 | ||
| */ | ||
| actions: CommitActionData[]; | ||
| /** | ||
| * 作者邮箱 | ||
| */ | ||
| author_email?: string; | ||
| /** | ||
| * 作者姓名 | ||
| */ | ||
| author_name?: string; | ||
| /** | ||
| * 提交状态 | ||
| * | ||
| * @default true | ||
| */ | ||
| stats?: boolean; | ||
| /** | ||
| * 强行提交 | ||
| * | ||
| * @description `true`的时候将会覆盖掉`start_branch`和`start_sha`的提交信息 | ||
| */ | ||
| force?: boolean; | ||
| } | ||
| interface CreateCommitExistBranch extends CreateCommitBaseData { | ||
| /** | ||
| * 当前提交的基点分支 | ||
| */ | ||
| branch: string; | ||
| } | ||
| /** 提交数据 */ | ||
| export type CreateCommitData = CreateCommitExistBranch; | ||
| interface CommitBaseData { | ||
| /** | ||
| * 文件路径 | ||
| */ | ||
| file_path: string; | ||
| /** | ||
| * 编码方式 | ||
| * | ||
| * @default 'text' | ||
| */ | ||
| encoding?: FileEncoding; | ||
| } | ||
| interface CommitCreateActionData extends CommitBaseData { | ||
| /** | ||
| * 创建文件 | ||
| */ | ||
| action: 'create'; | ||
| /** | ||
| * 文件内容 | ||
| */ | ||
| content: string; | ||
| } | ||
| interface CommitDeleteActionData extends CommitBaseData { | ||
| /** | ||
| * 删除文件 | ||
| */ | ||
| action: 'delete'; | ||
| /** | ||
| * 文件上次提交的编号 | ||
| */ | ||
| last_commit_id: string; | ||
| } | ||
| interface CommitMoveActionData extends CommitBaseData { | ||
| /** | ||
| * 移动文件 | ||
| */ | ||
| action: 'move'; | ||
| /** | ||
| * 文件之前的路径 | ||
| */ | ||
| previous_path: string; | ||
| /** | ||
| * 文件上次提交的编号 | ||
| */ | ||
| last_commit_id: string; | ||
| } | ||
| interface CommitUpdateActionData extends CommitBaseData { | ||
| /** | ||
| * 更新文件 | ||
| */ | ||
| action: 'update'; | ||
| /** | ||
| * 文件内容 | ||
| */ | ||
| content: string; | ||
| /** | ||
| * 文件上次提交的编号 | ||
| */ | ||
| last_commit_id: string; | ||
| } | ||
| interface CommitChmodActionData extends CommitBaseData { | ||
| /** | ||
| * 更新文件 | ||
| */ | ||
| action: 'chmod'; | ||
| /** | ||
| * 文件能否被执行 | ||
| */ | ||
| execute_filemode: boolean; | ||
| } | ||
| /** 提交行为数据 */ | ||
| export type CommitActionData = CommitCreateActionData | CommitDeleteActionData | CommitMoveActionData | CommitUpdateActionData | CommitChmodActionData; | ||
| export interface LsTreeData extends Project { | ||
| /** | ||
| * 检出文件的基路径 | ||
| * | ||
| * @default '/' | ||
| */ | ||
| path?: string; | ||
| /** | ||
| * 递归检出所有文件 | ||
| * | ||
| * @default false | ||
| */ | ||
| recursive?: boolean; | ||
| /** | ||
| * 是否启用分页 | ||
| * | ||
| * @default 'keyset' | ||
| */ | ||
| pagination?: 'keyset'; | ||
| /** | ||
| * 使用分页时每页的文件数量 | ||
| * | ||
| * @default 20 | ||
| */ | ||
| per_page?: number; | ||
| /** | ||
| * 下一页标记 | ||
| * | ||
| * @description 此值保存在返回值的`headers`里,字段为`x-next-page` | ||
| * @link https://docs.gitlab.com/ee/api/rest/index.html#other-pagination-headers | ||
| * @description gitlab 升级到 15 之后,此字段将会改为`page_token` | ||
| * @link https://docs.gitlab.com/ee/api/repositories.html#list-repository-tree | ||
| * | ||
| */ | ||
| page?: number; | ||
| /** | ||
| * 检出文件所在的分支或者是标签 | ||
| * | ||
| * @default 默认分支 | ||
| */ | ||
| ref?: string; | ||
| } | ||
| export interface LsTreeItemData { | ||
| id: string; | ||
| name: string; | ||
| path: string; | ||
| type: 'blob' | 'tree'; | ||
| mode: '100644' | '040000'; | ||
| } | ||
| export interface FileMetaData { | ||
| blob_id: string; | ||
| content_sha256: string; | ||
| encoding: FileEncoding; | ||
| ref: string; | ||
| size: number; | ||
| commit_id: string; | ||
| last_commit_id: string; | ||
| file_name: string; | ||
| file_path: string; | ||
| } | ||
| export interface FileData extends FileMetaData { | ||
| content: string; | ||
| execute_filemode: string; | ||
| } | ||
| /** 文件数据 */ | ||
| export interface InputFileData { | ||
| /** 文件硬盘路径 */ | ||
| diskPath: string; | ||
| /** 文件远端路径 */ | ||
| remotePath: string; | ||
| /** | ||
| * 文件内容 | ||
| * | ||
| * @description base64 编码 | ||
| */ | ||
| content: string; | ||
| /** | ||
| * 文件大小 | ||
| */ | ||
| size: number; | ||
| } | ||
| export interface CreateCommitResponseData { | ||
| id: string; | ||
| short_id: string; | ||
| title: string; | ||
| author_name: string; | ||
| author_email: string; | ||
| committer_name: string; | ||
| committer_email: string; | ||
| created_at: string; | ||
| message: string; | ||
| parent_ids: string[]; | ||
| committed_date: string; | ||
| authored_date: string; | ||
| stats: { | ||
| additions: number; | ||
| deletions: number; | ||
| total: number; | ||
| }; | ||
| status: null; | ||
| web_url: string; | ||
| } | ||
| export interface CreateMrData extends Project { | ||
| source_branch: string; | ||
| target_branch: string; | ||
| title: string; | ||
| allow_collaboration?: boolean; | ||
| /** allow_collaboration 的别名 */ | ||
| allow_maintainer_to_push?: boolean; | ||
| assignee_id?: number; | ||
| assignee_ids?: number[]; | ||
| description?: string; | ||
| /** | ||
| * MR 的标签 | ||
| * | ||
| * @description 使用分号分割 | ||
| */ | ||
| labels?: string; | ||
| milestone_id?: number; | ||
| remove_source_branch?: boolean; | ||
| reviewer_ids?: number; | ||
| /** MR 是否使用压缩提交 */ | ||
| squash?: boolean; | ||
| /** 目标项目 */ | ||
| target_project_id?: string; | ||
| } | ||
| export interface CreateMrResponseData extends Project { | ||
| id: number; | ||
| iid: number; | ||
| project_id: number; | ||
| title: string; | ||
| description: string; | ||
| state: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| target_branch: string; | ||
| source_branch: string; | ||
| upvotes: number; | ||
| downvotes: number; | ||
| author: { | ||
| id: number; | ||
| name: string; | ||
| username: string; | ||
| state: string; | ||
| avatar_url?: string; | ||
| web_url: string; | ||
| }; | ||
| assignee: { | ||
| id: number; | ||
| name: string; | ||
| username: string; | ||
| state: string; | ||
| avatar_url?: string; | ||
| web_url: string; | ||
| }; | ||
| source_project_id: number; | ||
| target_project_id: number; | ||
| labels: string[]; | ||
| draft: boolean; | ||
| work_in_progress: boolean; | ||
| milestone: { | ||
| id: number; | ||
| iid: number; | ||
| project_id: number; | ||
| title: string; | ||
| description: string; | ||
| state: string; | ||
| created_at: string; | ||
| updated_at: string; | ||
| due_date: string; | ||
| start_date: string; | ||
| web_url: string; | ||
| }; | ||
| merge_when_pipeline_succeeds: boolean; | ||
| merge_status: string; | ||
| detailed_merge_status: string; | ||
| merge_error?: string; | ||
| sha: string; | ||
| merge_commit_sha?: string; | ||
| squash_commit_sha?: string; | ||
| user_notes_count: number; | ||
| discussion_locked?: string; | ||
| should_remove_source_branch: boolean; | ||
| force_remove_source_branch: boolean; | ||
| allow_collaboration: boolean; | ||
| allow_maintainer_to_push: boolean; | ||
| web_url: string; | ||
| references: { | ||
| short: string; | ||
| relative: string; | ||
| full: string; | ||
| }; | ||
| time_stats: { | ||
| time_estimate: number; | ||
| total_time_spent: number; | ||
| human_time_estimate?: string; | ||
| human_total_time_spent?: string; | ||
| }; | ||
| squash: boolean; | ||
| subscribed: boolean; | ||
| changes_count: string; | ||
| merge_user: { | ||
| id: number; | ||
| name: string; | ||
| username: string; | ||
| state: string; | ||
| avatar_url: string; | ||
| web_url: string; | ||
| }; | ||
| merged_at: string; | ||
| prepared_at: string; | ||
| closed_by?: string; | ||
| closed_at?: string; | ||
| latest_build_started_at: string; | ||
| latest_build_finished_at: string; | ||
| first_deployed_to_production_at?: string; | ||
| pipeline: { | ||
| id: number; | ||
| sha: string; | ||
| ref: string; | ||
| status: string; | ||
| web_url: string; | ||
| }; | ||
| diff_refs: { | ||
| base_sha: string; | ||
| head_sha: string; | ||
| start_sha: string; | ||
| }; | ||
| diverged_commits_count: number; | ||
| task_completion_status: { | ||
| count: number; | ||
| completed_count: number; | ||
| }; | ||
| } | ||
| export interface CreateBranchData extends Project { | ||
| /** 新分支的名称 */ | ||
| branch: string; | ||
| /** 基准分支 */ | ||
| ref: string; | ||
| } | ||
| export interface CreateBranchResponseData extends Project { | ||
| commit: { | ||
| id: string; | ||
| short_id: string; | ||
| created_at: string; | ||
| parent_ids: string[]; | ||
| title: string; | ||
| message: string; | ||
| author_name: string; | ||
| author_email: string; | ||
| authored_date: string; | ||
| committer_name: string; | ||
| committer_email: string; | ||
| committed_date: string; | ||
| "trailers": {}; | ||
| web_url: string; | ||
| }; | ||
| name: string; | ||
| merged: boolean; | ||
| protected: boolean; | ||
| default: boolean; | ||
| developers_can_push: boolean; | ||
| developers_can_merge: boolean; | ||
| can_push: boolean; | ||
| web_url: string; | ||
| } | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const abc = { | ||
| commit_message: '', | ||
| branch: '', | ||
| actions: [], | ||
| }; | ||
| function test(datra) { } | ||
| test(abc); |
| export * from './log'; | ||
| export * from './secret'; | ||
| export * from './string'; | ||
| export * from './time'; | ||
| export * from './object'; | ||
| export * from './buffer'; | ||
| export * from './command'; | ||
| export * from './project'; | ||
| export * from './file'; | ||
| export * from './gitlab'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const tslib_1 = require("tslib"); | ||
| tslib_1.__exportStar(require("./log"), exports); | ||
| tslib_1.__exportStar(require("./secret"), exports); | ||
| tslib_1.__exportStar(require("./string"), exports); | ||
| tslib_1.__exportStar(require("./time"), exports); | ||
| tslib_1.__exportStar(require("./object"), exports); | ||
| tslib_1.__exportStar(require("./buffer"), exports); | ||
| tslib_1.__exportStar(require("./command"), exports); | ||
| tslib_1.__exportStar(require("./project"), exports); | ||
| tslib_1.__exportStar(require("./file"), exports); | ||
| tslib_1.__exportStar(require("./gitlab"), exports); |
| import chalk from 'chalk'; | ||
| import createSpinner from 'ora'; | ||
| export declare const color: chalk.Chalk; | ||
| export declare const logger: import("pino").Logger<{ | ||
| msgPrefix: string; | ||
| transport: { | ||
| target: string; | ||
| }; | ||
| }>; | ||
| export declare const spinner: createSpinner.Ora; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.spinner = exports.logger = exports.color = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const pino_1 = tslib_1.__importDefault(require("pino")); | ||
| const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
| const ora_1 = tslib_1.__importDefault(require("ora")); | ||
| exports.color = new chalk_1.default.Instance({ | ||
| level: 3, | ||
| }); | ||
| exports.logger = (0, pino_1.default)({ | ||
| msgPrefix: chalk_1.default.green('[LCAP Tool] '), | ||
| transport: { | ||
| target: 'pino-pretty', | ||
| }, | ||
| }); | ||
| exports.spinner = (0, ora_1.default)({ | ||
| interval: 200, | ||
| color: 'blue', | ||
| }); |
| export declare function shallowEqual<T extends Record<string, any>>(obj1: T, obj2: T): boolean; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.shallowEqual = void 0; | ||
| function shallowEqual(obj1, obj2) { | ||
| if (obj1 === obj2) { | ||
| return true; | ||
| } | ||
| const keys1 = Object.keys(obj1); | ||
| const keys2 = Object.keys(obj2); | ||
| // 如果两个对象的属性数量不同,则不相等 | ||
| if (keys1.length !== keys2.length) { | ||
| return false; | ||
| } | ||
| return keys1.every(key => obj1[key] === obj2[key]); | ||
| } | ||
| exports.shallowEqual = shallowEqual; |
| export declare function getVersion(root: string): Promise<string>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getVersion = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const path_1 = tslib_1.__importDefault(require("path")); | ||
| const promises_1 = require("fs/promises"); | ||
| async function getVersion(root) { | ||
| const packageJson = await (0, promises_1.readFile)(path_1.default.join(root, 'package.json'), 'utf-8'); | ||
| const { version } = JSON.parse(packageJson); | ||
| return version; | ||
| } | ||
| exports.getVersion = getVersion; |
| import type { Arguments } from 'yargs'; | ||
| export interface TokenData { | ||
| /** 发布密钥 */ | ||
| token?: string; | ||
| /** 发布密钥所在文件 */ | ||
| tokenFile?: string; | ||
| } | ||
| export declare function getSecretByFile<T>(file: string): Promise<T>; | ||
| export declare function getSecretByToken<T>(token: string): T; | ||
| export declare function transformSecretToToken(data: object): string; | ||
| export declare const tokenOptions: { | ||
| readonly token: { | ||
| readonly type: "string"; | ||
| readonly describe: "发布密钥"; | ||
| }; | ||
| readonly tokenFile: { | ||
| readonly type: "string"; | ||
| readonly describe: "发布密钥所在文件"; | ||
| }; | ||
| }; | ||
| export declare function tokenCheck(argv: Arguments<TokenData>): boolean; | ||
| export declare function getSecretByOption<T>(root: string, opt: TokenData): Promise<T>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getSecretByOption = exports.tokenCheck = exports.tokenOptions = exports.transformSecretToToken = exports.getSecretByToken = exports.getSecretByFile = void 0; | ||
| const promises_1 = require("fs/promises"); | ||
| const path_1 = require("path"); | ||
| function getSecretByFile(file) { | ||
| return (0, promises_1.readFile)(file, 'utf-8').then((val) => JSON.parse(val)); | ||
| } | ||
| exports.getSecretByFile = getSecretByFile; | ||
| function getSecretByToken(token) { | ||
| return JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); | ||
| } | ||
| exports.getSecretByToken = getSecretByToken; | ||
| function transformSecretToToken(data) { | ||
| return Buffer.from(JSON.stringify(data)).toString('base64'); | ||
| } | ||
| exports.transformSecretToToken = transformSecretToToken; | ||
| exports.tokenOptions = { | ||
| token: { | ||
| type: 'string', | ||
| describe: '发布密钥', | ||
| }, | ||
| tokenFile: { | ||
| type: 'string', | ||
| describe: '发布密钥所在文件', | ||
| }, | ||
| }; | ||
| function tokenCheck(argv) { | ||
| if (!argv.token && !argv.tokenFile) { | ||
| throw new Error('以下参数至少需要填入一个:token, tokenFile'); | ||
| } | ||
| return true; | ||
| } | ||
| exports.tokenCheck = tokenCheck; | ||
| async function getSecretByOption(root, opt) { | ||
| return opt.token | ||
| ? getSecretByToken(opt.token) | ||
| : getSecretByFile((0, path_1.isAbsolute)(opt.tokenFile) ? opt.tokenFile : (0, path_1.join)(root, opt.tokenFile)); | ||
| } | ||
| exports.getSecretByOption = getSecretByOption; |
| /** 分支名称格式化 */ | ||
| export declare function formatBranch(name: string): string; | ||
| /** 文本格式化 */ | ||
| export declare function formatMessage(message: string): string; | ||
| /** 格式化文本 */ | ||
| export declare function formatMessageByParams(input: string, data: Record<string, string | number>): string; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatMessageByParams = exports.formatMessage = exports.formatBranch = void 0; | ||
| /** 分支名称格式化 */ | ||
| function formatBranch(name) { | ||
| return name.replace(/[^\w]+/g, '-'); | ||
| } | ||
| exports.formatBranch = formatBranch; | ||
| /** 文本格式化 */ | ||
| function formatMessage(message) { | ||
| return message.replace(/\\+n/g, '\n'); | ||
| } | ||
| exports.formatMessage = formatMessage; | ||
| /** 格式化文本 */ | ||
| function formatMessageByParams(input, data) { | ||
| let content = input; | ||
| for (const key of Object.keys(data)) { | ||
| content = content.replace(`[${key}]`, String(data[key])); | ||
| } | ||
| return formatMessage(content); | ||
| } | ||
| exports.formatMessageByParams = formatMessageByParams; |
| export declare const delay: (time?: number) => Promise<void>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.delay = void 0; | ||
| const delay = (time) => { | ||
| return new Promise((resolve) => { | ||
| setTimeout(resolve, time); | ||
| }); | ||
| }; | ||
| exports.delay = delay; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
165749
111.28%7
-22.22%183
115.29%2678
11.44%2
100%2
100%+ Added
- Removed
Updated