@plugin-light/shared 0.0.22 → 1.0.1
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/README.md +6 -2
- package/lib/config/index.d.ts +4 -0
- package/lib/index.js +43 -23
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
除 `t-comm` 外,`plugin-light-shared` 是整个工具库中最底层的依赖。
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 1. 作者
|
|
15
|
+
|
|
16
|
+
**novlan1**
|
|
17
|
+
|
|
18
|
+
## 2. 如何使用
|
|
15
19
|
|
|
16
20
|
安装
|
|
17
21
|
|
|
@@ -27,6 +31,6 @@ import { getDeps } from '@plugin-light/shared';
|
|
|
27
31
|
getDeps(__dirname);
|
|
28
32
|
```
|
|
29
33
|
|
|
30
|
-
## 更新日志
|
|
34
|
+
## 3. 更新日志
|
|
31
35
|
|
|
32
36
|
[点此查看](./CHANGELOG.md)
|
package/lib/config/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export declare const PLATFORM_MAP: {
|
|
|
2
2
|
readonly MP_WX: "mp-weixin";
|
|
3
3
|
readonly MP_QQ: "mp-qq";
|
|
4
4
|
readonly MP_ALIPAY: "mp-alipay";
|
|
5
|
+
readonly MP_BAIDU: "mp-baidu";
|
|
6
|
+
readonly MP_TOUTIAO: "mp-toutiao";
|
|
7
|
+
readonly MP_KUAISHOU: "mp-kuaishou";
|
|
8
|
+
readonly MP_XHS: "mp-xhs";
|
|
5
9
|
readonly MP_JD: "mp-jd";
|
|
6
10
|
readonly H5: "h5";
|
|
7
11
|
};
|
package/lib/index.js
CHANGED
|
@@ -58,6 +58,10 @@ const PLATFORM_MAP = {
|
|
|
58
58
|
MP_WX: 'mp-weixin',
|
|
59
59
|
MP_QQ: 'mp-qq',
|
|
60
60
|
MP_ALIPAY: 'mp-alipay',
|
|
61
|
+
MP_BAIDU: 'mp-baidu',
|
|
62
|
+
MP_TOUTIAO: 'mp-toutiao',
|
|
63
|
+
MP_KUAISHOU: 'mp-kuaishou',
|
|
64
|
+
MP_XHS: 'mp-xhs',
|
|
61
65
|
MP_JD: 'mp-jd',
|
|
62
66
|
H5: 'h5',
|
|
63
67
|
};
|
|
@@ -248,6 +252,7 @@ const DEFAULT_KEYS = [
|
|
|
248
252
|
'MP_WEIXIN',
|
|
249
253
|
'MP_KUAISHOU',
|
|
250
254
|
'MP_JD',
|
|
255
|
+
'MP_XHS',
|
|
251
256
|
'QUICKAPP_NATIVE',
|
|
252
257
|
'QUICKAPP_WEBVIEW',
|
|
253
258
|
'QUICKAPP_WEBVIEW_HUAWEI',
|
|
@@ -409,6 +414,27 @@ function getSubProjectName() {
|
|
|
409
414
|
return name;
|
|
410
415
|
}
|
|
411
416
|
|
|
417
|
+
function updateManifestCore(_a) {
|
|
418
|
+
var path = _a.path,
|
|
419
|
+
value = _a.value,
|
|
420
|
+
manifest = _a.manifest;
|
|
421
|
+
var arr = path.split('.');
|
|
422
|
+
var len = arr.length;
|
|
423
|
+
var lastItem = arr[len - 1];
|
|
424
|
+
var i = 0;
|
|
425
|
+
var manifestArr = manifest.split(/\n/);
|
|
426
|
+
for (var index = 0; index < manifestArr.length; index++) {
|
|
427
|
+
var item = manifestArr[index];
|
|
428
|
+
if (new RegExp("\"".concat(arr[i], "\"")).test(item)) i = i + 1;
|
|
429
|
+
if (i === len) {
|
|
430
|
+
var hasComma = /,/.test(item);
|
|
431
|
+
manifestArr[index] = item.replace(new RegExp("\"".concat(lastItem, "\"[\\s\\S]*:[\\s\\S]*")), "\"".concat(lastItem, "\": ").concat(value).concat(hasComma ? ',' : ''));
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return manifestArr.join('\n');
|
|
436
|
+
}
|
|
437
|
+
|
|
412
438
|
// 读取 manifest.json ,修改后重新写入
|
|
413
439
|
const manifestPath = `${process.env.UNI_INPUT_DIR}/manifest.json`;
|
|
414
440
|
let originManifest = '';
|
|
@@ -418,26 +444,12 @@ try {
|
|
|
418
444
|
catch (err) {
|
|
419
445
|
}
|
|
420
446
|
let Manifest = originManifest;
|
|
421
|
-
function replaceManifest(path, value) {
|
|
422
|
-
const arr = path.split('.');
|
|
423
|
-
const len = arr.length;
|
|
424
|
-
const lastItem = arr[len - 1];
|
|
425
|
-
let i = 0;
|
|
426
|
-
const ManifestArr = Manifest.split(/\n/);
|
|
427
|
-
for (let index = 0; index < ManifestArr.length; index++) {
|
|
428
|
-
const item = ManifestArr[index];
|
|
429
|
-
if (new RegExp(`"${arr[i]}"`).test(item))
|
|
430
|
-
i = i + 1;
|
|
431
|
-
if (i === len) {
|
|
432
|
-
const hasComma = /,/.test(item);
|
|
433
|
-
ManifestArr[index] = item.replace(new RegExp(`"${lastItem}"[\\s\\S]*:[\\s\\S]*`), `"${lastItem}": ${value}${hasComma ? ',' : ''}`);
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
Manifest = ManifestArr.join('\n');
|
|
438
|
-
}
|
|
439
447
|
function updateManifest(path, value) {
|
|
440
|
-
|
|
448
|
+
Manifest = updateManifestCore({
|
|
449
|
+
path,
|
|
450
|
+
value,
|
|
451
|
+
manifest: Manifest,
|
|
452
|
+
});
|
|
441
453
|
fs__namespace.writeFileSync(manifestPath, Manifest, {
|
|
442
454
|
flag: 'w',
|
|
443
455
|
});
|
|
@@ -635,18 +647,26 @@ function getMpVersionCode() {
|
|
|
635
647
|
return `
|
|
636
648
|
var uni = (typeof wx !== 'undefined' && wx)
|
|
637
649
|
|| (typeof qq !== 'undefined' && qq)
|
|
650
|
+
|| (typeof swan !== 'undefined' && swan)
|
|
638
651
|
|| (typeof jd !== 'undefined' && jd)
|
|
652
|
+
|| (typeof tt !== 'undefined' && tt)
|
|
653
|
+
|| (typeof kuaishou !== 'undefined' && kuaishou)
|
|
654
|
+
|| (typeof xhs !== 'undefined' && xhs)
|
|
639
655
|
|| (typeof my !== 'undefined' && my);
|
|
640
656
|
|
|
641
657
|
var miniProgram = (uni.getAccountInfoSync && uni.getAccountInfoSync().miniProgram) || {};
|
|
642
|
-
var
|
|
658
|
+
var { envVersion = '', version = '' } = miniProgram;
|
|
659
|
+
function getSystemInfo() {
|
|
660
|
+
return (uni.getSystemInfoSync && uni.getSystemInfoSync()) || {};
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
var { pixelRatio } = (uni.getWindowInfo && uni.getWindowInfo()) || getSystemInfo();
|
|
664
|
+
var { brand, model, pixelRatio } = (uni.getDeviceInfo && uni.getDeviceInfo()) || getSystemInfo();
|
|
643
665
|
var envVersionMap = {
|
|
644
666
|
develop: '开发版',
|
|
645
667
|
trial: '体验版',
|
|
646
668
|
release: '正式版'
|
|
647
|
-
}
|
|
648
|
-
var { envVersion = '', version = '' } = miniProgram;
|
|
649
|
-
var { brand, model, pixelRatio } = systemInfo;
|
|
669
|
+
};
|
|
650
670
|
var versionDesc = \`\${envVersion}(\${envVersionMap[envVersion] || ''})\`;
|
|
651
671
|
|
|
652
672
|
console.info('[system]', '');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugin-light/shared",
|
|
3
|
-
"version": "
|
|
4
|
-
"homepage": "https://novlan1.github.io/plugin-light/zh/plugin-light-shared.html",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"homepage": "https://novlan1.github.io/docs/plugin-light/zh/plugin-light-shared.html",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/novlan1/plugin-light/issues"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lib/"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"t-comm": "
|
|
19
|
+
"t-comm": "latest"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "rm -rf lib && rollup -c",
|