@infly/libs 2.0.25

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/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@infly/libs",
3
+ "version": "2.0.25",
4
+ "description": "工具组件库",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "postinstall": "node index.js",
9
+ "publishPkg": "npm version patch && npm publish --access=public --registry=https://registry.npmjs.org/",
10
+ "preview": "infly-libs --preview",
11
+ "preview:no-build": "infly-libs --preview --no-build"
12
+ },
13
+ "bin": {
14
+ "infly-libs": "bin/cli.js"
15
+ },
16
+ "exports": {
17
+ "./module/*": "./module/*",
18
+ "./dataInit/*": "./dataInit/*",
19
+ "./tools/*": "./tools/*",
20
+ "./store/*": "./store/*",
21
+ "./build/*": "./build/*"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://gitee.com/kahal/npm-package"
26
+ },
27
+ "keywords": [
28
+ "infly",
29
+ "infly-libs",
30
+ "libs"
31
+ ],
32
+ "types-为了直接点击进入引用文件所以去掉": "types/index.d.ts",
33
+ "author": "Kahal",
34
+ "license": "ISC",
35
+ "dependencies": {},
36
+ "devDependencies-仅在需要webpack时候删除": {
37
+ "@babel/core": "^7.27.3",
38
+ "@babel/preset-env": "^7.27.2",
39
+ "babel-loader": "^10.0.0",
40
+ "webpack": "^5.99.9",
41
+ "webpack-cli": "^6.0.1",
42
+ "webpack-node-externals": "^3.0.0"
43
+ },
44
+ "peerDependencies": {
45
+ "axios": "^0.27.2",
46
+ "html-webpack-plugin": "^5.5.3"
47
+ },
48
+ "optionalDependencies": {
49
+ "axios": "^0.27.2",
50
+ "html-webpack-plugin": "^5.5.3"
51
+ },
52
+ "infly": {
53
+ "zipOptions": {
54
+ "buildFoldName": "[构建后目录名] 可选, 默认取值vue.config.js的outputDir, 配置化 eg: postal-benefits-level-pc",
55
+ "outputPath": "[输出文件目录链接] eg: ./ ",
56
+ "enabled": "[是否启用压缩] eg: true",
57
+ "gitAuto": "[是否自动提交git] eg: true",
58
+ "gitAutoPushRepos": "[自动提交推送git构建仓库] eg: frontend",
59
+ "gitAutoPushReposBranchMap": {
60
+ "release-eg": "develop-eg [自动提交推送项目构建分支和构建仓库推送分支对应配置,必须]"
61
+ },
62
+ "gitAutoCommitText": "[自动提交文案] eg: build: 更新版本为v{version}, 推送构建文件与zip压缩包 --build by infly-libs",
63
+ "enablePreview": "[是否启用项目预览] eg: true",
64
+ "enableClipboard": "[是否启用粘贴板粘贴git信息] eg: true",
65
+ "openExplorer": "[是否自动打开资源管理器] eg: true",
66
+ "webhookUrl": "[消息推送机器人链接配置] eg: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2417edd3-8f74-4c30-a7a8-5a72826d40d2",
67
+ "webhookAtUser": [
68
+ "@人手机号"
69
+ ],
70
+ "webhookExtraText": "[消息推送额外文案] eg: 麻烦发下版",
71
+ "compressionLevel": 9
72
+ },
73
+ "versionConfig": {
74
+ "mainVersion": "[主版本号] 可选, 默认取值项目package version, eg: 1",
75
+ "links": {
76
+ "master": "[master分支构建文件推送地址] eg: e.sutpay.com",
77
+ "release": "[release分支构建文件推送地址] eg: http://114.132.55.214:8081/"
78
+ },
79
+ "platformName": "[用以split的项目平台名称] eg: 邮惠权益平台-运营端",
80
+ "baseName": "v{version}-{timestamp}.zip",
81
+ "versionList": [],
82
+ "disableUpdateVersionEnv": [
83
+ "development",
84
+ "staging [禁用更新版本号的环境, 比如测试环境构建不需要更新version, 不配置默认禁用stage测试环境]"
85
+ ]
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,44 @@
1
+ const path = require('path');
2
+ const { checkAndUpdatePackages } = require('./index');
3
+
4
+ // 设置基本的日志颜色
5
+ global.logColor = {
6
+ success: '\x1b[32m', // 绿色
7
+ error: '\x1b[31m', // 红色
8
+ warning: '\x1b[33m', // 黄色
9
+ info: '\x1b[36m', // 青色
10
+ reset: '\x1b[0m' // 重置
11
+ };
12
+
13
+ /**
14
+ * 主函数:检查 packages 并处理
15
+ */
16
+ function main() {
17
+ // packages 目录路径(相对于当前脚本的位置)
18
+ const packagesDir = path.resolve(__dirname, '../../../../packages');
19
+
20
+ console.log(global.logColor.info, `\n🔍 开始检查 packages 目录: ${packagesDir}\n`);
21
+
22
+ try {
23
+ // 执行完整的检查和更新流程
24
+ // 如果有未提交代码会自动中止并退出进程
25
+ // 如果没有问题会自动切换到 master 分支并拉取最新代码
26
+ checkAndUpdatePackages(packagesDir, 'master');
27
+
28
+ console.log(global.logColor.success, `\n✨ packages 检查和更新完成,可以继续执行后续操作!\n`);
29
+
30
+ // 在这里可以继续执行你的其他逻辑
31
+ // 比如构建、发布等操作
32
+
33
+ } catch (error) {
34
+ console.error(global.logColor.error, `\n💥 执行失败: ${error.message}\n`);
35
+ process.exit(1);
36
+ }
37
+ }
38
+
39
+ // 如果直接运行此文件,则执行主函数
40
+ if (require.main === module) {
41
+ main();
42
+ }
43
+
44
+ module.exports = { main };
@@ -0,0 +1,69 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { execSync } = require("child_process");
4
+
5
+ // 读取配置文件
6
+ const projectRoot = process.cwd().replace(/\\node_modules.*$/g, "");
7
+ const projectPkgPath = path.resolve(projectRoot, "package.json");
8
+ const config = JSON.parse(fs.readFileSync(projectPkgPath, "utf-8"));
9
+ const { projectConfig } = config || {};
10
+ const { autoCloneProject, gitBranch, baseGitUrl } = projectConfig || {};
11
+
12
+ function cloneRepository(url, branch, targetDir) {
13
+ try {
14
+ execSync(`git clone -b ${branch} ${url} ${targetDir}`);
15
+ console.log(global.logColor.success, `✅ 项目克隆成功: ${path.basename(targetDir)}`);
16
+ } catch (err) {
17
+ console.error(global.logColor.error, `❌ 项目克隆失败: ${url} ${err.message}`);
18
+ }
19
+ }
20
+
21
+ /**
22
+ * 批量克隆项目
23
+ * @param {Array} projects
24
+ * @returns
25
+ * @description
26
+ * eg: package.json
27
+ * {
28
+ "name": "postal-benefits-monorepo",
29
+ "version": "1.0.0",
30
+ "private": true,
31
+ "projectConfig": {
32
+ "autoCloneProject": true,
33
+ "gitBranch": "master",
34
+ "baseGitUrl": "https://gitee.com/gdinfly_1/"
35
+ },
36
+ "workspaces": [
37
+ "apps/postal-benefits-platform",
38
+ "apps/postal-benefits-platform-merchant",
39
+ "apps/postal-benefits-platform-level"
40
+ ]
41
+ }
42
+ *
43
+ */
44
+ function batchCloneProject(projects = config.workspaces || [], autoClone = autoCloneProject) {
45
+ if (typeof autoClone === "boolean" && !autoClone) {
46
+ process.exit(0);
47
+ }
48
+
49
+ if (autoClone) {
50
+ if (!Array.isArray(projects) || projects.length === 0) {
51
+ console.log(global.logColor.warning, "⚠️ 没有可克隆的项目或配置错误。");
52
+ process.exit(1);
53
+ }
54
+ console.log(global.logColor.success, `🚀 项目克隆开始 =======>`);
55
+ projects.forEach((repo = "") => {
56
+ const [targetFileDir = "", projectName = ""] = repo.split("/");
57
+ const repoUrl = baseGitUrl + projectName + ".git";
58
+ const targetDir = path.resolve(projectRoot, repo);
59
+ cloneRepository(repoUrl, gitBranch, targetDir);
60
+ });
61
+ console.log(global.logColor.success, `🚀 项目克隆完成 =======>`);
62
+ process.exit(0);
63
+ }
64
+ }
65
+
66
+ module.exports = {
67
+ cloneRepository,
68
+ batchCloneProject
69
+ };
@@ -0,0 +1,17 @@
1
+ const { execSync } = require("child_process");
2
+
3
+ function submoduleInit() {
4
+ try {
5
+ execSync("git submodule update --init --recursive", { stdio: "inherit" });
6
+ console.log("✅ Git子模块初始化完成");
7
+ } catch (error) {
8
+ console.error("❌ Git命令执行失败:", error.message);
9
+ process.exit(1);
10
+ }
11
+ }
12
+
13
+ submoduleInit();
14
+
15
+ module.exports = {
16
+ submoduleInit
17
+ };