From f790f04c3785be8559c028331dacc59c3b7b4e99 Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Fri, 2 Aug 2024 13:09:40 +0800 Subject: [PATCH] =?UTF-8?q?uni=5Fmodules=5Ftools=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=97=A0=E6=B3=95=E5=8F=91=E5=B8=83=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules.config.json | 6 -- uni_modules/uni-id-pages/changelog.md | 4 +- uni_modules_tools/change_after.js | 27 ------- uni_modules_tools/config.js | 86 --------------------- uni_modules_tools/main.js | 103 -------------------------- uni_modules_tools/package-lock.json | 31 -------- uni_modules_tools/package.json | 14 ---- uni_modules_tools/readme.md | 84 --------------------- 8 files changed, 2 insertions(+), 353 deletions(-) delete mode 100644 uni_modules.config.json delete mode 100644 uni_modules_tools/change_after.js delete mode 100644 uni_modules_tools/config.js delete mode 100644 uni_modules_tools/main.js delete mode 100644 uni_modules_tools/package-lock.json delete mode 100644 uni_modules_tools/package.json delete mode 100644 uni_modules_tools/readme.md diff --git a/uni_modules.config.json b/uni_modules.config.json deleted file mode 100644 index 3d01554..0000000 --- a/uni_modules.config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "scripts":{ - "preupload": "node uni_modules_tools/main.js change", - "postupload": "node uni_modules_tools/main.js recovery" - } -} \ No newline at end of file diff --git a/uni_modules/uni-id-pages/changelog.md b/uni_modules/uni-id-pages/changelog.md index 5347f84..60be677 100644 --- a/uni_modules/uni-id-pages/changelog.md +++ b/uni_modules/uni-id-pages/changelog.md @@ -1,5 +1,5 @@ -## 1.1.21(2024-08-02) -- uni-id-co 修复联登更新用户信息接口存在手机号或者邮箱时没有设置认证状态 +## 1.1.21(2024-08-02) +- uni-id-co 修复联登更新用户信息接口存在手机号或者邮箱时没有设置认证状态 ## 1.1.20(2024-04-28) - uni-id-co 兼容uni-app-x对客户端uniPlatform的调整(uni-app-x内uniPlatform区分app-android、app-ios) ## 1.1.19(2024-03-20) diff --git a/uni_modules_tools/change_after.js b/uni_modules_tools/change_after.js deleted file mode 100644 index 431dc4e..0000000 --- a/uni_modules_tools/change_after.js +++ /dev/null @@ -1,27 +0,0 @@ -const fs = require('fs'); -module.exports = function(){ - console.log('开始执行脚本change_after'); -/* let changelog = fs.readFileSync(process.cwd() + '/changelog.md', 'utf-8').split("##")[1].split("\n").slice(1).join(' '); - console.log(changelog); - // 这里是修改完相关敏感配置后执行的脚本,你可以在这里自定义逻辑, - - - // 比如执行git提交命令 - var shell = require("shelljs"); - var exec = shell.exec; - - if (exec('git add .').code !== 0) { - shell.echo('Error: Git add failed'); - shell.exit(1); - } - if (exec(`git commit -a -m "${changelog}"`).code !== 0) { - shell.echo('Error: Git commit failed'); - shell.exit(1); - } - if (exec('git push').code !== 0) { - shell.echo('Error: Git commit failed'); - shell.exit(1); - } - shell.exec(`echo git success ${changelog}`); - */ -} \ No newline at end of file diff --git a/uni_modules_tools/config.js b/uni_modules_tools/config.js deleted file mode 100644 index 455b494..0000000 --- a/uni_modules_tools/config.js +++ /dev/null @@ -1,86 +0,0 @@ -// "文件路径" : {"键名":"改成什么"} -{ - "/manifest.json": { - "appid": "", - "name": "", - "versionName": "", - "mp-weixin": { - "appid": "" - }, - "vueVersion": "2", - "app-plus": { - "modules": { - "OAuth": {} - }, - "distribute": { - "sdkConfigs": { - "oauth": { - "univerify": {}, - "weixin": { - "appid": "", - "appsecret": "", - "UniversalLinks": "" - }, - "apple": {} - } - } - } - } - }, - "/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json": { - "passwordSecret": "passwordSecretDemo", - "tokenSecret": "tokenSecretDemo", - "tokenExpiresIn": 7200, - "app": { - "oauth": { - "weixin": { - "appid": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appid", - "appsecret": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appsecret" - }, - "apple": { - "bundleId": "苹果开发者后台获取的bundleId" - } - } - }, - "web": { - "oauth": { - "weixin-h5": { - "appid": "微信浏览器内微信登录,所用的微信公众号appid", - "appsecret": "微信公众号后台获取的appsecret" - }, - "weixin-web": { - "appid": "手机微信扫码登录,所用的微信开放平台(https://open.weixin.qq.com/)-网站应用的appid", - "appsecret": "微信开放平台-网站应用的appsecret" - } - } - }, - "mp-weixin": { - "oauth": { - "weixin": { - "appid": "微信小程序登录所用的appid、appsecret需要在对应的小程序管理控制台获取", - "appsecret": "微信小程序后台获取的appsecret" - } - } - }, - "mp-alipay": { - "oauth": { - "alipay": { - "appid": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr", - "privateKey": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr" - } - } - }, - "service": { - "sms": { - "name": "应用名称,对应短信模版的name", - "smsKey": "短信密钥key,开通短信服务处可以看到", - "smsSecret": "短信密钥secret,开通短信服务处可以看到" - }, - "univerify": { - "appid": "当前应用的appid,使用云函数URL化,此项必须配置", - "apiKey": "apiKey 和 apiSecret 在开发者中心获取,开发者中心:https://dev.dcloud.net.cn/uniLogin/index?type=0,文档:https://ask.dcloud.net.cn/article/37965", - "apiSecret": "" - } - } - } -} diff --git a/uni_modules_tools/main.js b/uni_modules_tools/main.js deleted file mode 100644 index 475ce97..0000000 --- a/uni_modules_tools/main.js +++ /dev/null @@ -1,103 +0,0 @@ -//脚本文件目录 __dirname -//运行脚本的目录,即:项目的目录 process.cwd() - -//配置文件 -const fs = require('fs'), - Hjson = require('hjson'), - config = Hjson.rt.parse(fs.readFileSync(__dirname+'/config.js', 'utf-8')) -const change_after = require('./change_after') - -if(process.argv[2] == 'change'){ - change(config,()=>{ - console.log('脚本change已经执行成功'); - change_after() - }) -}else{ - recovery(config) -} - -function change(config,callback){ - const total = Object.keys(config).length - let index = 0; - for (let fileName in config) { - let path = process.cwd() + fileName - let copyPath = __dirname + '/copy' + fileName - let fileText = fs.readFileSync(path, 'utf-8') - //保持原文件名先备份一份到/uni_modules_tools/copy目录下,然后再覆盖 - writeFileRecursive(copyPath, fileText, function(err) { //创建目录并写入文件 - if (err) { - return console.log(err); - } - //改写 - let HfileObj = Hjson.rt.parse(fileText) - //递归合并,为了保留注释内容 - mergeJSON(HfileObj,config[fileName]) - - fs.writeFile(path, Hjson.rt.stringify(HfileObj, { - quotes: 'all', - separator: true, - multiline: "off", - bracesSameLine: true - }), function(err) { - if (err) { - return console.log(err); - } - index++ - if(index == total){ - callback() - } - }) - }) - } -} - - - - -function recovery(){ - let paths = Object.keys(config) - console.log(paths); - paths.forEach(path=>{ - console.log(__dirname + '/copy' + path); - let oldFile = fs.readFileSync(__dirname + '/copy' + path) - console.log(process.cwd() + path); - fs.writeFile(process.cwd() + path, oldFile, function(err) { - if (err) { - console.log(err); - return - } - // fs.unlinkSync(__dirname + path+'.lock') - }) - }) -} - - - - - - -//创建目录并写入文件 -function writeFileRecursive(path, buffer, callback) { - let lastPath = path.substring(0, path.lastIndexOf("/")); - fs.mkdir(lastPath, { - recursive: true - }, (err) => { - if (err) return callback(err); - fs.writeFile(path, buffer, function(err) { - if (err) return callback(err); - return callback(null); - }); - }); -} - -//递归合并,为了保留注释内容 -function mergeJSON(minor, main) { - for (var key in main) { - if (typeof(main[key]) != 'object' ) { - minor[key] = main[key]; - }else{ - console.log('[',minor[key], main[key],']'); - mergeJSON(minor[key], main[key]); - } - } -} \ No newline at end of file diff --git a/uni_modules_tools/package-lock.json b/uni_modules_tools/package-lock.json deleted file mode 100644 index fa4b3db..0000000 --- a/uni_modules_tools/package-lock.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "uni_modules_tools", - "version": "1.0.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "uni_modules_tools", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "hjson": "^3.2.2" - } - }, - "node_modules/hjson": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/hjson/-/hjson-3.2.2.tgz", - "integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q==", - "bin": { - "hjson": "bin/hjson" - } - } - }, - "dependencies": { - "hjson": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/hjson/-/hjson-3.2.2.tgz", - "integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q==" - } - } -} diff --git a/uni_modules_tools/package.json b/uni_modules_tools/package.json deleted file mode 100644 index 5fdc537..0000000 --- a/uni_modules_tools/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "uni_modules_tools", - "version": "1.0.0", - "description": "本插件是一个[uni_modules钩子脚本](https://uniapp.dcloud.io/uni_modules?id=uni_modulesconfigjson),仅限uni_modules插件使用 #### 为什么使用 uni_modules_tools 在实际开发中很多插件需要配置文件才可以正常运行,比如uni-id、uni-pay等; 有些配置内容属于密钥,在发表到插件市场的时候我们通常不希望这些配置被暴露。 传统的方式你需要手动备份密钥内容,上传结束后再将配置填回。这样插件作者发表插件会比较不便。", - "main": "main.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "hjson": "^3.2.2" - } -} diff --git a/uni_modules_tools/readme.md b/uni_modules_tools/readme.md deleted file mode 100644 index dc309e5..0000000 --- a/uni_modules_tools/readme.md +++ /dev/null @@ -1,84 +0,0 @@ -本插件是一个[uni_modules钩子脚本](https://uniapp.dcloud.io/uni_modules?id=uni_modulesconfigjson),仅限uni_modules插件使用 -#### 为什么使用 uni_modules_tools -在实际开发中很多插件需要配置文件才可以正常运行,比如uni-id、uni-pay等; -有些配置内容属于密钥,在发表到插件市场的时候我们通常不希望这些配置被暴露。 -传统的方式你需要手动备份密钥内容,上传结束后再将配置填回。这样插件作者发表插件会比较不便。 - -而现在有了 `uni_modules_tools` 只需配置`/uni_modules_tools/config.js`即实现 -- 在插件上传之前,自动根据配置改写项目中对应配置。 -- 上传结束(成功和失败都触发)后自动恢复项目中的配置。 - -#### 示例目录结构 -
-├─ uni_modules						// 存放uni_module规范的插件。
-│	└─uni-config-center
-│		└─uniCloud
-│			└─cloudfunctions
-│				└─common
-│					└─uni-config-center
-│						└─uni-id
-│							└─config.json
-├─ manifest.json
-├─ uni_modules.config.json		//uni_modules的配置文件
-└─ uni_modules_tools
-	├─ copy						//用于自动修改配置文件时的,临时备份目录
-	├─ config.js				//插件配置文件,下面会有示例说明
-	├─ main.js					//插件核心代码,入口文件;你无需修改此文件中的代码,除非你了解内部逻辑
-	└─ readme.md 				//插件文档
-
- - -#### 使用方式 -`/uni_modules_tools/config.js`的格式为: -``` -{ - "文件路径" : {"键名":"改后的内容"} -} -``` - -- 文件仅支持json格式,如:`manifest.json`、`uni-config-center`下的`config.json`等 - -使用示例,比如你需要: -- 修改manifest.json文件的appid内容改为:请重新获取appid -- 修改uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json 文件的内容app-plus -> oauth -> weixin 和 apple 下的 `appid` `appsecret` `apple`值为:`请填写你的自己的appid` `请填写你的自己的appsecret` `请填写你的自己的bundleId` - -1. 配置,根目录下的`/uni_modules_tools/config.js`文件,如下: - -``` -{ - "/manifest.json": { - "appid": "请重新获取appid" - }, - "/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json": { - "app-plus": { - "oauth": { - "weixin": { - "appid": "请填写你的自己的appid", - "appsecret": "请填写你的自己的appsecret" - }, - "apple": { - "bundleId": "请填写你的自己的bundleId" - } - } - } - } -} -``` - -2. 根目录下的`/uni_modules.config.json`配置如下: -``` -{ - "scripts":{ - "preupload": "node uni_modules_tools/main.js change", - "postupload": "node uni_modules_tools/main.js recovery" - } -} -``` - -3. 项目依赖hjson-js需要在uni_modules_tools目录,执行npm install完成依赖的安装 - -#### 测试方式 -- 在项目根目录直接执行 `node uni_modules_tools/main.js change` 即可测试修改相关配置的效果 -- 在项目根目录直接执行 `node uni_modules_tools/main.js recovery` 即可测试恢复相关配置的效果 - -> 本插件中使用了[hjson-js](https://www.npmjs.com/package/hjson) 感谢@hjson-js的作者 \ No newline at end of file -- GitLab