next-admin-svr 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -8,6 +8,7 @@ var mongodb = require('mongodb');
8
8
  var shared = require('@plugin-light/shared');
9
9
  var Fontmin = require('fontmin');
10
10
  var multer = require('multer');
11
+ var minimatch = require('minimatch');
11
12
  var crypto = require('@wecom/crypto');
12
13
  var agentSdk = require('@tencent-ai/agent-sdk');
13
14
  var croner = require('croner');
@@ -18,6 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
19
  var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
19
20
  var Fontmin__default = /*#__PURE__*/_interopDefaultLegacy(Fontmin);
20
21
  var multer__default = /*#__PURE__*/_interopDefaultLegacy(multer);
22
+ var minimatch__default = /*#__PURE__*/_interopDefaultLegacy(minimatch);
21
23
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto$1);
22
24
 
23
25
  const defaultModule = {
@@ -33,7 +35,9 @@ const defaultModule = {
33
35
  aggregate: () => Promise.resolve([]),
34
36
  },
35
37
  landun: {
38
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
36
39
  startPipeline: () => Promise.resolve({}),
40
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
37
41
  startPipelineByRawApi: () => Promise.resolve({}),
38
42
  },
39
43
  auth: {
@@ -1429,9 +1433,17 @@ router$6.post('/start-publish', async (req, res) => {
1429
1433
  const staffName = (req.header('rid') || 'developer');
1430
1434
  const toolName = (req.header('x-mcp-tool-name') || '');
1431
1435
  const { mcpName, mcpVersion, repo, branch, publishReason, subProjectName, } = req.body;
1436
+ if (!repo || !branch) {
1437
+ res.json({
1438
+ r: -1,
1439
+ code: -1,
1440
+ msg: '缺少必要参数: repo 和 branch 是必填项',
1441
+ });
1442
+ return;
1443
+ }
1432
1444
  const result = await shared.startMpCIPipeline({
1433
1445
  repo,
1434
- subProject: subProjectName,
1446
+ subProject: subProjectName || '',
1435
1447
  branch,
1436
1448
  staffName,
1437
1449
  isWeixin: true,
@@ -1443,7 +1455,43 @@ router$6.post('/start-publish', async (req, res) => {
1443
1455
  mcpDB: coreModule.get().mcpDB,
1444
1456
  toolName,
1445
1457
  });
1446
- res.send(result);
1458
+ // 获取审批人信息
1459
+ let auditorInfo = { auditor: '', shouldAudit: false };
1460
+ try {
1461
+ auditorInfo = await tComm.getAuditor({
1462
+ type: 'rainbow',
1463
+ configSource: async () => {
1464
+ const res = await tComm.fetchRainbowConfig('h5_publish_auditor', {
1465
+ appId: process.env.RAINBOW_APP_ID,
1466
+ userId: process.env.RAINBOW_USER_ID,
1467
+ secretKey: process.env.RAINBOW_SECRET_KEY,
1468
+ envName: 'Default',
1469
+ groupName: 'devops_open',
1470
+ }, {
1471
+ sdk: shared.getRainbowNodeSdk(),
1472
+ tryJsonParse: true,
1473
+ });
1474
+ console.log('auditor', res);
1475
+ return res;
1476
+ },
1477
+ rainbowOptions: {
1478
+ projectName: shared.extractRepoPath(repo),
1479
+ subProjectName: subProjectName || '',
1480
+ // @ts-ignore
1481
+ minimatch: minimatch__default["default"],
1482
+ },
1483
+ skipAudit: branch !== 'release',
1484
+ });
1485
+ }
1486
+ catch (e) {
1487
+ console.error('[MP Publish MCP] 获取审批人失败:', e);
1488
+ }
1489
+ // 在返回结果中追加审批人信息
1490
+ if (result.result && typeof result.result === 'object') {
1491
+ result.result.auditor = auditorInfo.auditor;
1492
+ result.result.shouldAudit = auditorInfo.shouldAudit;
1493
+ }
1494
+ res.json(result);
1447
1495
  });
1448
1496
 
1449
1497
  const router$5 = express__default["default"].Router();
@@ -1511,6 +1559,40 @@ router$4.post('/mcp-start', async (req, res) => {
1511
1559
  operationTool: coreModule.get().operation,
1512
1560
  toolName,
1513
1561
  });
1562
+ // 获取审批人信息
1563
+ let auditorInfo = { auditor: '', shouldAudit: false };
1564
+ try {
1565
+ auditorInfo = await tComm.getAuditor({
1566
+ type: 'json',
1567
+ configSource: async () => {
1568
+ const res = await tComm.fetchRainbowConfig('library_publish_auditor', {
1569
+ appId: process.env.RAINBOW_APP_ID,
1570
+ userId: process.env.RAINBOW_USER_ID,
1571
+ secretKey: process.env.RAINBOW_SECRET_KEY,
1572
+ envName: 'Default',
1573
+ groupName: 'devops_open',
1574
+ }, {
1575
+ sdk: shared.getRainbowNodeSdk(),
1576
+ tryJsonParse: true,
1577
+ });
1578
+ console.log('auditor', res);
1579
+ return res;
1580
+ },
1581
+ jsonOptions: {
1582
+ projectName: shared.extractRepoPath(component.git),
1583
+ key: versionType,
1584
+ },
1585
+ });
1586
+ }
1587
+ catch (e) {
1588
+ console.error('[Pipeline Open] 获取审批人失败:', e);
1589
+ }
1590
+ console.log('[auditorInfo]', auditorInfo, component, versionType);
1591
+ // 在返回结果中追加审批人信息
1592
+ if (result?.result?.data && typeof result?.result?.data === 'object') {
1593
+ (result?.result?.data).auditor = auditorInfo.auditor;
1594
+ (result?.result?.data).shouldAudit = auditorInfo.shouldAudit;
1595
+ }
1514
1596
  res.send(result);
1515
1597
  });
1516
1598
 
package/lib/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  import express from 'express';
2
- import { timeStampFormat, batchSendWxRobotMarkdown, uploadCOSStreamFile, purgeUrlCache, uploadCOSStreamFileV2, uploadCOSFile, createIwikiDoc, saveJsonToLog } from 't-comm';
2
+ import { timeStampFormat, batchSendWxRobotMarkdown, uploadCOSStreamFile, purgeUrlCache, uploadCOSStreamFileV2, uploadCOSFile, getAuditor, fetchRainbowConfig, createIwikiDoc, saveJsonToLog } from 't-comm';
3
3
  import { ObjectId } from 'mongodb';
4
- import { getUploadCosConfig, createFontProjectOrUpdate, cosSyncToGit, FONT_PROJECT_WEBHOOK_URL, getOneCdnUrl, getPushUrlCacheArea, createIconProjectOrUpdate, ICON_PROJECT_PIPELINE_CONFIG, ICON_PROJECT_WEBHOOK_URL, parseImage, getUploadImageFilePath, uploadFilesCore, compressFileUseTinypng, startMpCIPipeline, startNPMPublishPipelineCore, getComponentByRepo, getWhiteRainbowConfig, WHITE_USER_PIPELINE_ID, WHITE_USER_STATUS_MAP, getWhiteTypeDesc, updateWhiteUserCosByDb, watchEmails, toCdnUrl } from '@plugin-light/shared';
4
+ import { getUploadCosConfig, createFontProjectOrUpdate, cosSyncToGit, FONT_PROJECT_WEBHOOK_URL, getOneCdnUrl, getPushUrlCacheArea, createIconProjectOrUpdate, ICON_PROJECT_PIPELINE_CONFIG, ICON_PROJECT_WEBHOOK_URL, parseImage, getUploadImageFilePath, uploadFilesCore, compressFileUseTinypng, startMpCIPipeline, getRainbowNodeSdk, extractRepoPath, startNPMPublishPipelineCore, getComponentByRepo, getWhiteRainbowConfig, WHITE_USER_PIPELINE_ID, WHITE_USER_STATUS_MAP, getWhiteTypeDesc, updateWhiteUserCosByDb, watchEmails, toCdnUrl } from '@plugin-light/shared';
5
5
  import Fontmin from 'fontmin';
6
6
  import multer from 'multer';
7
+ import minimatch from 'minimatch';
7
8
  import { decrypt } from '@wecom/crypto';
8
9
  import { query } from '@tencent-ai/agent-sdk';
9
10
  import { Cron } from 'croner';
@@ -22,7 +23,9 @@ const defaultModule = {
22
23
  aggregate: () => Promise.resolve([]),
23
24
  },
24
25
  landun: {
26
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
25
27
  startPipeline: () => Promise.resolve({}),
28
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
26
29
  startPipelineByRawApi: () => Promise.resolve({}),
27
30
  },
28
31
  auth: {
@@ -1418,9 +1421,17 @@ router$6.post('/start-publish', async (req, res) => {
1418
1421
  const staffName = (req.header('rid') || 'developer');
1419
1422
  const toolName = (req.header('x-mcp-tool-name') || '');
1420
1423
  const { mcpName, mcpVersion, repo, branch, publishReason, subProjectName, } = req.body;
1424
+ if (!repo || !branch) {
1425
+ res.json({
1426
+ r: -1,
1427
+ code: -1,
1428
+ msg: '缺少必要参数: repo 和 branch 是必填项',
1429
+ });
1430
+ return;
1431
+ }
1421
1432
  const result = await startMpCIPipeline({
1422
1433
  repo,
1423
- subProject: subProjectName,
1434
+ subProject: subProjectName || '',
1424
1435
  branch,
1425
1436
  staffName,
1426
1437
  isWeixin: true,
@@ -1432,7 +1443,43 @@ router$6.post('/start-publish', async (req, res) => {
1432
1443
  mcpDB: coreModule.get().mcpDB,
1433
1444
  toolName,
1434
1445
  });
1435
- res.send(result);
1446
+ // 获取审批人信息
1447
+ let auditorInfo = { auditor: '', shouldAudit: false };
1448
+ try {
1449
+ auditorInfo = await getAuditor({
1450
+ type: 'rainbow',
1451
+ configSource: async () => {
1452
+ const res = await fetchRainbowConfig('h5_publish_auditor', {
1453
+ appId: process.env.RAINBOW_APP_ID,
1454
+ userId: process.env.RAINBOW_USER_ID,
1455
+ secretKey: process.env.RAINBOW_SECRET_KEY,
1456
+ envName: 'Default',
1457
+ groupName: 'devops_open',
1458
+ }, {
1459
+ sdk: getRainbowNodeSdk(),
1460
+ tryJsonParse: true,
1461
+ });
1462
+ console.log('auditor', res);
1463
+ return res;
1464
+ },
1465
+ rainbowOptions: {
1466
+ projectName: extractRepoPath(repo),
1467
+ subProjectName: subProjectName || '',
1468
+ // @ts-ignore
1469
+ minimatch,
1470
+ },
1471
+ skipAudit: branch !== 'release',
1472
+ });
1473
+ }
1474
+ catch (e) {
1475
+ console.error('[MP Publish MCP] 获取审批人失败:', e);
1476
+ }
1477
+ // 在返回结果中追加审批人信息
1478
+ if (result.result && typeof result.result === 'object') {
1479
+ result.result.auditor = auditorInfo.auditor;
1480
+ result.result.shouldAudit = auditorInfo.shouldAudit;
1481
+ }
1482
+ res.json(result);
1436
1483
  });
1437
1484
 
1438
1485
  const router$5 = express.Router();
@@ -1500,6 +1547,40 @@ router$4.post('/mcp-start', async (req, res) => {
1500
1547
  operationTool: coreModule.get().operation,
1501
1548
  toolName,
1502
1549
  });
1550
+ // 获取审批人信息
1551
+ let auditorInfo = { auditor: '', shouldAudit: false };
1552
+ try {
1553
+ auditorInfo = await getAuditor({
1554
+ type: 'json',
1555
+ configSource: async () => {
1556
+ const res = await fetchRainbowConfig('library_publish_auditor', {
1557
+ appId: process.env.RAINBOW_APP_ID,
1558
+ userId: process.env.RAINBOW_USER_ID,
1559
+ secretKey: process.env.RAINBOW_SECRET_KEY,
1560
+ envName: 'Default',
1561
+ groupName: 'devops_open',
1562
+ }, {
1563
+ sdk: getRainbowNodeSdk(),
1564
+ tryJsonParse: true,
1565
+ });
1566
+ console.log('auditor', res);
1567
+ return res;
1568
+ },
1569
+ jsonOptions: {
1570
+ projectName: extractRepoPath(component.git),
1571
+ key: versionType,
1572
+ },
1573
+ });
1574
+ }
1575
+ catch (e) {
1576
+ console.error('[Pipeline Open] 获取审批人失败:', e);
1577
+ }
1578
+ console.log('[auditorInfo]', auditorInfo, component, versionType);
1579
+ // 在返回结果中追加审批人信息
1580
+ if (result?.result?.data && typeof result?.result?.data === 'object') {
1581
+ (result?.result?.data).auditor = auditorInfo.auditor;
1582
+ (result?.result?.data).shouldAudit = auditorInfo.shouldAudit;
1583
+ }
1503
1584
  res.send(result);
1504
1585
  });
1505
1586
 
@@ -1,3 +1,4 @@
1
+ import { type StartPipelineResult } from '@plugin-light/shared';
1
2
  import { Request, Response } from 'express';
2
3
  interface MongoDb {
3
4
  connect(): Promise<any>;
@@ -32,12 +33,12 @@ interface OperationTool {
32
33
  updateRecord(where: any, record: any): Promise<void>;
33
34
  }
34
35
  interface Landun {
35
- startPipeline(pipelineId: string, data: any): Promise<any>;
36
+ startPipeline(pipelineId: string, data: any): Promise<StartPipelineResult>;
36
37
  startPipelineByRawApi(options: {
37
38
  data: any;
38
39
  pipelineId: string;
39
40
  userName: string;
40
- }): Promise<any>;
41
+ }): Promise<StartPipelineResult>;
41
42
  }
42
43
  interface CoreModuleData {
43
44
  mongodb: MongoDb;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-admin-svr",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Next Admin 服务端",
5
5
  "keywords": [
6
6
  "vue3",
@@ -35,6 +35,7 @@
35
35
  "croner": "^9.1.0",
36
36
  "express": "^5.2.1",
37
37
  "fontmin": "latest",
38
+ "minimatch": "^10.0.1",
38
39
  "mongodb": "^7.0.0",
39
40
  "multer": "^2.0.2",
40
41
  "t-comm": "latest",