miniprogram-ci 1.9.10 → 1.9.13
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/CHANGELOG.md +3 -0
- package/README.md +71 -1
- package/dist/@types/ci/checkCodeQuality.d.ts +3 -0
- package/dist/@types/ci/utils/codeDenpendencyQualityChecker.d.ts +31 -0
- package/dist/@types/ci/utils/qualitycheckoption.d.ts +50 -0
- package/dist/@types/config.d.ts +2 -1
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/types/index.d.ts +46 -0
- package/dist/@types/utils/locales/locales.d.ts +1 -0
- package/dist/ci/checkCodeQuality.js +3 -0
- package/dist/ci/projectattr.js +1 -1
- package/dist/ci/utils/codeDenpendencyQualityChecker.js +3 -0
- package/dist/ci/utils/qualitycheckoption.js +3 -0
- package/dist/cli.js +1 -1
- package/dist/config.js +1 -1
- package/dist/core/json/app/checkAppFields.js +1 -1
- package/dist/core/json/reactiveCache.js +1 -1
- package/dist/core/worker_thread/task/compilejs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/types/index.js +1 -1
- package/dist/utils/locales/locales.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ miniprogram-ci 是从[微信开发者工具](https://developers.weixin.qq.com/mi
|
|
|
7
7
|
miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,调用方式与普通开发模式无异。[查看详情](#第三方平台开发)
|
|
8
8
|
|
|
9
9
|
## 最近变更
|
|
10
|
+
#### 1.9.11
|
|
11
|
+
- `new` 新增 `checkCodeQuality` 代码质量检查能力。
|
|
10
12
|
#### 1.9.10
|
|
11
13
|
- `new` 新增 支持 compileWorklet 编译选项。
|
|
12
14
|
#### 1.9.9
|
|
@@ -651,6 +653,66 @@ const ci = require('miniprogram-ci')
|
|
|
651
653
|
}
|
|
652
654
|
```
|
|
653
655
|
|
|
656
|
+
### 代码质量检查
|
|
657
|
+
对应开发者工具的[代码质量扫描](https://developers.weixin.qq.com/miniprogram/dev/devtools/quality.html)的功能,输出质量扫描结果。
|
|
658
|
+
|
|
659
|
+
```javascript
|
|
660
|
+
const ci = require('miniprogram-ci')
|
|
661
|
+
;(async () => {
|
|
662
|
+
const project = new ci.Project({
|
|
663
|
+
appid: 'wxsomeappid',
|
|
664
|
+
type: 'miniProgram',
|
|
665
|
+
projectPath: 'the/project/path',
|
|
666
|
+
privateKeyPath: 'the/path/to/privatekey', // checkCodeQuality 方法不会读取 private key
|
|
667
|
+
})
|
|
668
|
+
|
|
669
|
+
const res = await ci.checkCodeQuality(project)
|
|
670
|
+
console.warn('code quality' + result)
|
|
671
|
+
})()
|
|
672
|
+
```
|
|
673
|
+
#### 质量扫描结果说明
|
|
674
|
+
质量扫描结果是一个包含多个检查结果对象的数组。
|
|
675
|
+
每个检查项对象包含以下字段:
|
|
676
|
+
* name (字符串):检查项的名称。
|
|
677
|
+
* success (布尔值):代码是否满足此检查。
|
|
678
|
+
* text (字符串):检查结果描述。
|
|
679
|
+
* docURL (字符串):相关文档的 URL。
|
|
680
|
+
* detail (对象):检查项结果详细信息(在此描述中不展开)。
|
|
681
|
+
|
|
682
|
+
| name - 检查项名字 | detail |
|
|
683
|
+
|--------------------------|----------------------------|
|
|
684
|
+
| PACKAGE_SIZE_LIMIT | 包含各个子包的大小信息 |
|
|
685
|
+
| JS_COMPRESS_OPEN | 无 |
|
|
686
|
+
| WXML_COMPRESS_OPEN | 无 |
|
|
687
|
+
| WXSS_COMPRESS_OPEN | 无 |
|
|
688
|
+
| LAZYCODE_LOADING_OPEN | 无 |
|
|
689
|
+
| IMAGE_AND_AUDIO_LIMIT | 无 |
|
|
690
|
+
| CONTAINS_OTHER_PKG_JS | 包含主包中仅被其他子包依赖的 JS 文件信息 |
|
|
691
|
+
| CONTAINS_OTHER_PKG_COMPONENTS | 包含主包中仅被其他分包依赖的组件信息 |
|
|
692
|
+
| CONTAINS_UNUSED_PLUGINS | 包含未使用的插件信息 |
|
|
693
|
+
| CONTAINS_UNUSED_COMPONENTS | 包含未使用的组件信息 |
|
|
694
|
+
| CONTAINS_UNUSED_CODES | 包含无依赖文件的信息 |
|
|
695
|
+
|
|
696
|
+
示例:
|
|
697
|
+
```js
|
|
698
|
+
[
|
|
699
|
+
{
|
|
700
|
+
"name": "PACKAGE_SIZE_LIMIT",
|
|
701
|
+
"success": false,
|
|
702
|
+
"text": "Main package size (without plugins) should be less than 1.5 M",
|
|
703
|
+
"docURL": "https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",
|
|
704
|
+
"detail": {...}
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"name": "JS_COMPRESS_OPEN",
|
|
708
|
+
"success": true,
|
|
709
|
+
"text": "JS compression is not turned on",
|
|
710
|
+
"docURL": "https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",
|
|
711
|
+
"detail": {...}
|
|
712
|
+
},
|
|
713
|
+
...
|
|
714
|
+
]
|
|
715
|
+
```
|
|
654
716
|
|
|
655
717
|
### 代理
|
|
656
718
|
|
|
@@ -722,6 +784,14 @@ miniprogram-ci \
|
|
|
722
784
|
--enable-es6 true \
|
|
723
785
|
--save-path ./compiledResult.zip
|
|
724
786
|
|
|
787
|
+
#check-code-quality
|
|
788
|
+
miniprogram-ci \
|
|
789
|
+
check-code-quality \
|
|
790
|
+
--pp ./demo-proj/ \
|
|
791
|
+
--pkp ./private.YOUR_APPID.key \
|
|
792
|
+
--appid YOUR_APPID \
|
|
793
|
+
--save-path ./report.json
|
|
794
|
+
|
|
725
795
|
#pack-npm
|
|
726
796
|
miniprogram-ci \
|
|
727
797
|
pack-npm \
|
|
@@ -809,7 +879,7 @@ miniprogram-ci \
|
|
|
809
879
|
| 键 | 类型 | 说明 |
|
|
810
880
|
| -------------- | ------- | ----------------------------------------------------------- |
|
|
811
881
|
| es6 | boolean | 对应于微信开发者工具的 "es6 转 es5" |
|
|
812
|
-
| es7 | boolean | 对应于微信开发者工具的 "增强编译"
|
|
882
|
+
| es7 | boolean | 对应于微信开发者工具的 "增强编译",且支持编译 worklet 代码 |
|
|
813
883
|
| disableUseStrict | boolean | "增强编译" 开启时,是否禁用JS文件严格模式,默认为false |
|
|
814
884
|
| minifyJS | boolean | 上传时压缩 JS 代码 |
|
|
815
885
|
| minifyWXML | boolean | 上传时压缩 WXML 代码 |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Analyzer } from '../../vendor/code-analyse';
|
|
2
|
+
import { IProject } from '../../types';
|
|
3
|
+
export declare class CodeDenpendencyQualityChecker {
|
|
4
|
+
private analyzer;
|
|
5
|
+
private subpackageRoots?;
|
|
6
|
+
private babelRoot;
|
|
7
|
+
constructor(project: IProject, analyzer: Analyzer);
|
|
8
|
+
checkUnusedCodeFiles(): string[];
|
|
9
|
+
checkUnusedMiniProgramCodeFiles(): string[];
|
|
10
|
+
checkOnlyUsedByOtherPackagesJs(): {
|
|
11
|
+
size: number;
|
|
12
|
+
files: string[];
|
|
13
|
+
};
|
|
14
|
+
checkMainPackageUnusedComponents(): {
|
|
15
|
+
size: number;
|
|
16
|
+
files: string[];
|
|
17
|
+
comps: string[];
|
|
18
|
+
};
|
|
19
|
+
checkUnusedPlugins(): Promise<string[]>;
|
|
20
|
+
checkUnusedComponents(): Promise<string[]>;
|
|
21
|
+
private get graph();
|
|
22
|
+
private getSubpackageRoots;
|
|
23
|
+
private isLocateInMainPackage;
|
|
24
|
+
caculateFilesSize(files: string[]): number;
|
|
25
|
+
caculateResourceFileSize(extList: string[]): number;
|
|
26
|
+
caculatePackageSize(): {
|
|
27
|
+
[key: string]: number;
|
|
28
|
+
};
|
|
29
|
+
private collectCompsFiles;
|
|
30
|
+
private reservedFile;
|
|
31
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
version: number;
|
|
3
|
+
checkList: ({
|
|
4
|
+
name: string;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
desc: string;
|
|
7
|
+
descEn: string;
|
|
8
|
+
limit: number;
|
|
9
|
+
docURL: string;
|
|
10
|
+
level: number;
|
|
11
|
+
title: string;
|
|
12
|
+
titleEn: string;
|
|
13
|
+
typeName: string;
|
|
14
|
+
typeNameEn: string;
|
|
15
|
+
handlerText?: undefined;
|
|
16
|
+
handlerTextEn?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
name: string;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
desc: string;
|
|
21
|
+
descEn: string;
|
|
22
|
+
docURL: string;
|
|
23
|
+
level: number;
|
|
24
|
+
title: string;
|
|
25
|
+
titleEn: string;
|
|
26
|
+
typeName: string;
|
|
27
|
+
typeNameEn: string;
|
|
28
|
+
limit?: undefined;
|
|
29
|
+
handlerText?: undefined;
|
|
30
|
+
handlerTextEn?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
name: string;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
desc: string;
|
|
35
|
+
descEn: string;
|
|
36
|
+
level: number;
|
|
37
|
+
handlerText: string;
|
|
38
|
+
handlerTextEn: string;
|
|
39
|
+
title: string;
|
|
40
|
+
titleEn: string;
|
|
41
|
+
docURL: string;
|
|
42
|
+
typeName: string;
|
|
43
|
+
typeNameEn: string;
|
|
44
|
+
limit?: undefined;
|
|
45
|
+
})[];
|
|
46
|
+
regList: {
|
|
47
|
+
IMAGE_AND_AUDIO_LIMIT: string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
package/dist/@types/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CI_VERSION = "1.9.
|
|
1
|
+
export declare const CI_VERSION = "1.9.13";
|
|
2
2
|
export declare const PARAM_ERROR = 10000;
|
|
3
3
|
export declare const WXML_NOT_FOUND = 10007;
|
|
4
4
|
export declare const JS_NOT_FOUND = 10008;
|
|
@@ -59,6 +59,7 @@ export declare const DefaultProjectAttr: {
|
|
|
59
59
|
MaxSubPackageLimit: number;
|
|
60
60
|
MinTabbarCount: number;
|
|
61
61
|
MaxTabbarCount: number;
|
|
62
|
+
MaxCustomTabbarCount: number;
|
|
62
63
|
MaxTabbarIconSize: number;
|
|
63
64
|
};
|
|
64
65
|
};
|
package/dist/@types/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { analyseCode } from './ci/code-analyse';
|
|
|
13
13
|
import { getCompiledResult } from './ci/getCompiledResult';
|
|
14
14
|
import { getLatestVersion } from './ci/getLatestVersion';
|
|
15
15
|
import { getWhiteExtList } from './utils/white_ext_list';
|
|
16
|
+
import { checkCodeQuality } from './ci/checkCodeQuality';
|
|
16
17
|
export { Project };
|
|
17
18
|
export type { IUploadOptions };
|
|
18
19
|
export declare const upload: typeof _upload;
|
|
@@ -32,6 +33,7 @@ export declare const cloud: {
|
|
|
32
33
|
export { uploadJsServer };
|
|
33
34
|
export { getLatestVersion };
|
|
34
35
|
export { analyseCode };
|
|
36
|
+
export { checkCodeQuality };
|
|
35
37
|
export { getWhiteExtList };
|
|
36
38
|
export * from './core';
|
|
37
39
|
export * from './summer';
|
|
@@ -105,6 +105,7 @@ export declare namespace MiniProgramCI {
|
|
|
105
105
|
MaxSubPackageLimit: number;
|
|
106
106
|
MinTabbarCount: number;
|
|
107
107
|
MaxTabbarCount: number;
|
|
108
|
+
MaxCustomTabbarCount: number;
|
|
108
109
|
MaxTabbarIconSize: number;
|
|
109
110
|
};
|
|
110
111
|
}
|
|
@@ -121,3 +122,48 @@ export type ProjectType = MiniProgramCI.ProjectType;
|
|
|
121
122
|
export type IProject = MiniProgramCI.IProject;
|
|
122
123
|
export type IStat = MiniProgramCI.IStat;
|
|
123
124
|
export type IAnyObject = MiniProgramCI.IAnyObject;
|
|
125
|
+
export declare const CheckOption: {
|
|
126
|
+
PACKAGE_SIZE_LIMIT: number;
|
|
127
|
+
IMAGE_AND_AUDIO_LIMIT: number;
|
|
128
|
+
CONTAINS_OTHER_PKG_JS: number;
|
|
129
|
+
CONTAINS_OTHER_PKG_COMPONENTS: number;
|
|
130
|
+
CONTAINS_OTHER_PKG_PLUGINS: number;
|
|
131
|
+
JS_COMPRESS_OPEN: number;
|
|
132
|
+
WXML_COMPRESS_OPEN: number;
|
|
133
|
+
WXSS_COMPRESS_OPEN: number;
|
|
134
|
+
CONTAINS_UNUSED_PLUGINS: number;
|
|
135
|
+
PLUGIN_OVER_SIZE: number;
|
|
136
|
+
USE_EXTENDLIB_WITHOUT_DEFINED: number;
|
|
137
|
+
LAZYCODE_LOADING_OPEN: number;
|
|
138
|
+
CONTAINS_UNUSED_COMPONENTS: number;
|
|
139
|
+
CONTAINS_UNUSED_CODES: number;
|
|
140
|
+
CONTAINS_APPSECRET: number;
|
|
141
|
+
};
|
|
142
|
+
export type ICheckOption = keyof typeof CheckOption;
|
|
143
|
+
export interface ICheckItemList {
|
|
144
|
+
version?: number;
|
|
145
|
+
checkList?: ICheckItem[];
|
|
146
|
+
regList?: {
|
|
147
|
+
[optionName: string]: any;
|
|
148
|
+
};
|
|
149
|
+
innerPluginAppidList?: string[];
|
|
150
|
+
}
|
|
151
|
+
export interface ICheckItem {
|
|
152
|
+
name?: ICheckOption;
|
|
153
|
+
enabled: boolean;
|
|
154
|
+
desc: string;
|
|
155
|
+
descEn: string;
|
|
156
|
+
docURL?: string;
|
|
157
|
+
level: number;
|
|
158
|
+
handlerText?: string;
|
|
159
|
+
handlerTextEn?: string;
|
|
160
|
+
text?: string;
|
|
161
|
+
limit?: number;
|
|
162
|
+
detail?: any;
|
|
163
|
+
title: string;
|
|
164
|
+
titleEn: string;
|
|
165
|
+
typeName: string;
|
|
166
|
+
typeNameEn: string;
|
|
167
|
+
success?: boolean;
|
|
168
|
+
}
|
|
169
|
+
export type ICheckResultItem = Pick<ICheckItem, 'name' | 'success' | 'text' | 'detail' | 'docURL'>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkCodeQuality=exports.transCompileType=void 0;const tslib_1=require("tslib"),projectconfig_1=require("../core/json/projectconfig"),code_analyse_1=require("../vendor/code-analyse"),path_1=tslib_1.__importDefault(require("path")),qualitycheckoption_1=tslib_1.__importDefault(require("./utils/qualitycheckoption")),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),fomatable_string_1=require("../utils/locales/fomatable_string"),codeDenpendencyQualityChecker_1=require("./utils/codeDenpendencyQualityChecker");function transCompileType(e){if("miniProgram"===e.type)return"miniprogram";if("miniProgramPlugin"===e.type)return"plugin";if("miniGame"===e.type)return"game";if("miniGamePlugin"===e.type)return"gamePlugin";throw new Error("unknown compile type "+e.type)}async function checkCodeQuality(e){const t=transCompileType(e);if("gamePlugin"===t)throw new Error("gamePlugin is not support yet!");if("game"===t)throw new Error("game is not support yet!");if("plugin"===t)throw new Error("plugin is not support yet!");const s=new QualityChecker;return await s.check({project:e}),s.getResult()}exports.transCompileType=transCompileType,exports.checkCodeQuality=checkCodeQuality;const formatDesc=(e,...t)=>{const s=locales_1.default.getLocale();e.text="en"===s?new fomatable_string_1.FormatableString(e.descEn||"").format(...t):new fomatable_string_1.FormatableString(e.desc||"").format(...t)};class QualityChecker{constructor(){this.result=[],this._checkConfig=qualitycheckoption_1.default,this.checkerHandlerMap=new Map,this._codeDepsCheckerPromise=null,this.checkJSCompressIsOpen=async(e,t)=>{var s;let c=!1;formatDesc(e);return c=!!(null===(s=(await(0,projectconfig_1.getProjectConfigJSON)(t.project)).setting)||void 0===s?void 0:s.minified),c},this.checkWXMLCompressIsOpen=async(e,t)=>{var s;let c=!1;formatDesc(e);return c=!!(null===(s=(await(0,projectconfig_1.getProjectConfigJSON)(t.project)).setting)||void 0===s?void 0:s.minifyWXML),c},this.checkWXSSCompressIsOpen=async(e,t)=>{var s;let c=!1;formatDesc(e);return c=!!(null===(s=(await(0,projectconfig_1.getProjectConfigJSON)(t.project)).setting)||void 0===s?void 0:s.minifyWXSS),c},this.checkLazyCodeLoadingIsOpen=async(e,t)=>{let s=!1;formatDesc(e);const c=await(0,projectconfig_1.getProjectConfigJSON)(t.project),{miniprogramRoot:i=""}=c,n=await t.project.getFile(i,"app.json");return s=!!JSON.parse(n.toString("utf-8")).lazyCodeLoading,s},this.checkImageAndAudioSizeLimit=async(e,t)=>{const s=await this.getCodeDepsChecker(t),c=e.limit||200,i=s.caculateResourceFileSize(this._checkConfig.regList.IMAGE_AND_AUDIO_LIMIT)/1024<c;return formatDesc(e,""+c),i},this.checkPackageSizeLimit=async(e,t)=>{const s=(await this.getCodeDepsChecker(t)).caculatePackageSize(),c=e.limit||1.5,i=1024*c;let n=!0;formatDesc(e,""+c);for(const e of Object.values(s))e/1024>i&&(n=!1);return e.detail=s,n},this.getCodeDepsChecker=async e=>{const t=e.project;return this._codeDepsCheckerPromise||(this._codeDepsCheckerPromise=new Promise((s,c)=>{let i=(0,projectconfig_1.getProjectConfigJSON)(t).miniprogramRoot;i=i?path_1.default.posix.join(t.projectPath,i):t.projectPath;const n=new code_analyse_1.Analyzer({root:i,type:"miniprogram",plugins:[]});n.analyse().then(()=>{s(new codeDenpendencyQualityChecker_1.CodeDenpendencyQualityChecker(e.project,n))}).catch(e=>{c(e)})})),this._codeDepsCheckerPromise},this.checkJSDepsOnlyUsedByOtherSubPkg=async(e,t)=>{const s=(await this.getCodeDepsChecker(t)).checkOnlyUsedByOtherPackagesJs();e.detail=s,formatDesc(e,":");let c=!0;return s.size>0&&s.files.length>0&&(c=!1),c},this.checkComponentDepsOnlyUsedByOtherSubPkg=async(e,t)=>{const s=(await this.getCodeDepsChecker(t)).checkMainPackageUnusedComponents();return e.detail=s,formatDesc(e,":"),!0},this.checkUnusedPlugins=async(e,t)=>{const s=await this.getCodeDepsChecker(t),c=await s.checkUnusedPlugins();e.detail=c;let i=!0;return formatDesc(e,""+c.join(" , ")),c.length>0&&(i=!1),i},this.checkUnusedComponents=async(e,t)=>{const s=await this.getCodeDepsChecker(t),c=await s.checkUnusedComponents();e.detail=c,formatDesc(e,":");let i=!0;return c.length>0&&(i=!1),i},this.checkUnusedCodes=async(e,t)=>{var s,c;const i=(await this.getCodeDepsChecker(t)).checkUnusedCodeFiles();e.detail=i,formatDesc(e,i.length);let n=!0;i.length>0&&(n=!1);const r=await(0,projectconfig_1.getProjectConfigJSON)(t.project);return!(!1===(null===(s=r.setting)||void 0===s?void 0:s.ignoreDevUnusedFiles)||!1===(null===(c=r.setting)||void 0===c?void 0:c.ignoreUploadUnusedFiles))||n},this.checkerHandlerMap.set("JS_COMPRESS_OPEN",this.checkJSCompressIsOpen),this.checkerHandlerMap.set("WXML_COMPRESS_OPEN",this.checkWXMLCompressIsOpen),this.checkerHandlerMap.set("WXSS_COMPRESS_OPEN",this.checkWXSSCompressIsOpen),this.checkerHandlerMap.set("LAZYCODE_LOADING_OPEN",this.checkLazyCodeLoadingIsOpen),this.checkerHandlerMap.set("IMAGE_AND_AUDIO_LIMIT",this.checkImageAndAudioSizeLimit),this.checkerHandlerMap.set("PACKAGE_SIZE_LIMIT",this.checkPackageSizeLimit),this.checkerHandlerMap.set("CONTAINS_OTHER_PKG_JS",this.checkJSDepsOnlyUsedByOtherSubPkg),this.checkerHandlerMap.set("CONTAINS_OTHER_PKG_COMPONENTS",this.checkComponentDepsOnlyUsedByOtherSubPkg),this.checkerHandlerMap.set("CONTAINS_UNUSED_COMPONENTS",this.checkUnusedComponents),this.checkerHandlerMap.set("CONTAINS_UNUSED_PLUGINS",this.checkUnusedPlugins),this.checkerHandlerMap.set("CONTAINS_UNUSED_CODES",this.checkUnusedCodes)}async check(e,t){t||(t=[...this.checkerHandlerMap.keys()]);const s=await this.getCheckList(t);return await this.checkList(s,e)}async getCheckList(e){var t;const s=new Set(e);try{return((null===(t=this._checkConfig)||void 0===t?void 0:t.checkList)||[]).filter(e=>s.has(e.name||"")).filter(e=>e.enabled)}catch(e){return console.log(e),[]}}async checkList(e,t){if(!(null==e?void 0:e.length))return[];const s=[];e.forEach(e=>{s.push(this.checkItem(e,t))});const c=await Promise.all(s);return this.result=c.filter(e=>null!==e).map(e=>{const{name:t,success:s,text:c,docURL:i,detail:n}=e;return{name:t,success:s,text:c,docURL:i,detail:n}}),this._codeDepsCheckerPromise=null,this.result}async checkItem(e,t){const s=e.name;if(s&&this.checkerHandlerMap.has(s)){const c=this.checkerHandlerMap.get(s);let i=!1;try{i=await c(e,t)}catch(e){i=!0,console.error(e)}return Object.assign(Object.assign({},e),{success:i})}return null}getResult(){return this.result}}
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
package/dist/ci/projectattr.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectAttr=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),sign_1=require("../utils/sign"),log_1=tslib_1.__importDefault(require("../utils/log")),config_1=require("../config"),url_config_1=require("../utils/url_config"),jsonParse_1=require("../utils/jsonParse"),testCache={};async function getProjectAttr(e,t){try{if(global.useAttrCache&&testCache[t])return testCache[t];const r=await(0,sign_1.getSignature)(e,t),{body:o}=await(0,request_1.request)({url:url_config_1.GET_ATTR_URL,method:"post",body:JSON.stringify({appid:t,signature:r}),headers:{"content-type":"application/json"}}),s=(0,jsonParse_1.jsonRespParse)(o,url_config_1.GET_ATTR_URL);if(0===s.errCode)return global.useAttrCache&&(testCache[t]=s.data),s.data;log_1.default.error(`get ${t} project attr fail errCode: ${s.errCode}, errMsg: ${s.errMsg}`)}catch(e){log_1.default.error(`get ${t} project attr fail ${e}`)}return config_1.DefaultProjectAttr}exports.getProjectAttr=getProjectAttr;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectAttr=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),sign_1=require("../utils/sign"),log_1=tslib_1.__importDefault(require("../utils/log")),config_1=require("../config"),url_config_1=require("../utils/url_config"),jsonParse_1=require("../utils/jsonParse"),testCache={};async function getProjectAttr(e,t){try{if(global.useAttrCache&&testCache[t])return testCache[t];const r=await(0,sign_1.getSignature)(e,t),{body:o}=await(0,request_1.request)({url:url_config_1.GET_ATTR_URL,method:"post",body:JSON.stringify({appid:t,signature:r}),headers:{"content-type":"application/json"}}),s=(0,jsonParse_1.jsonRespParse)(o,url_config_1.GET_ATTR_URL);if(0===s.errCode)return global.useAttrCache&&(testCache[t]=s.data),s.data;log_1.default.error(`get ${t} project attr fail errCode: ${s.errCode}, errMsg: ${s.errMsg}`)}catch(e){throw log_1.default.error(`get ${t} project attr fail ${e}`),e}return config_1.DefaultProjectAttr}exports.getProjectAttr=getProjectAttr;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodeDenpendencyQualityChecker=void 0;const tslib_1=require("tslib"),path=tslib_1.__importStar(require("path")),babel_helper_1=require("../../utils/babel_helper");function findParent(e,a,t,s){const i=new Set(Array.isArray(e)?e:[e]),r=new Set,n=new Set;for(;i.size>0;){const e=i.values().next().value;r.add(e),i.delete(e),t(e)&&n.add(e),(null==s?void 0:s(e))||e.parentDeps.forEach(e=>{e.originModule&&!r.has(e.originModule)&&i.add(e.originModule)})}return Array.from(n.values())}function isCodeFile(e){return/\.(json|wxml|wxss|js|wxs|ts|less|sass|scss)/.test(e)}function isMiniProgramCodeFile(e){return/\.(json|wxml|wxss|js|wxs)/.test(e)}function mapToMiniProgramFile(e){const a=path.posix.extname(e);return isMiniProgramCodeFile(a)?e:".ts"===a?e.substring(0,e.length-3)+".js":e.substring(0,e.length-5)+".wxss"}class CodeDenpendencyQualityChecker{constructor(e,a){if(this.analyzer=a,this.reservedFile=e=>e.indexOf(this.babelRoot)>=0,a.invalid)throw new Error("analyzer is invalid");if(!a.graph)throw new Error("analyzer graph is not built");this.babelRoot=(0,babel_helper_1.getBabelOutputPath)(e)}checkUnusedCodeFiles(){const e=this.analyzer.fileHelper.getFileList("").filter(e=>isCodeFile(path.posix.extname(e))),a=new Set;return this.analyzer.graph.modules.forEach(t=>{const s=e.find(e=>e===t.path);s&&a.add(s)}),e.forEach(e=>{this.reservedFile(e)&&a.add(e)}),e.filter(e=>!a.has(e))}checkUnusedMiniProgramCodeFiles(){if(0===this.analyzer.compilerPlugins.length)return this.checkUnusedCodeFiles();const e=this.analyzer.fileHelper.getFileList("").filter(e=>isCodeFile(path.posix.extname(e))),a=new Set;this.analyzer.graph.modules.forEach(t=>{const s=e.find(e=>e===t.path);s&&a.add(mapToMiniProgramFile(s))}),e.forEach(e=>{this.reservedFile(e)&&a.add(e)});const t=new Set;return e.forEach(e=>{const s=mapToMiniProgramFile(e);a.has(s)||t.add(s)}),Array.from(t.values())}checkOnlyUsedByOtherPackagesJs(){const e=this.graph.modules.filter(e=>"Js"===e.type&&this.isLocateInMainPackage(e)).filter(e=>{let a=!1;return e.parentDeps.forEach(e=>{e.originModule&&this.isLocateInMainPackage(e.originModule)&&(a=!0)}),!a}).map(e=>e.path).filter(e=>!this.reservedFile(e));return{size:this.caculateFilesSize(e),files:e}}checkMainPackageUnusedComponents(){const e=this.graph.modules.filter(e=>"Component"===e.type&&this.isLocateInMainPackage(e)).filter(e=>0===findParent(e,this.graph,e=>"Page"===e.type&&this.isLocateInMainPackage(e)||"MainPackage"===e.type,e=>"Page"===e.type).length);e.filter(e=>{for(const a of e.deps.values())if("Component"!==a.type&&a.module&&a.module.parentDeps.size>1)return!1;return!0});const a=this.collectCompsFiles(e);return{size:this.caculateFilesSize(a),files:a,comps:e.map(e=>e.path.replace(/\.json$/,""))}}async checkUnusedPlugins(){if("miniprogram"!==this.analyzer.type)throw new Error("checkUnusedPlugins only support miniprogram, the analyzer.type is "+this.analyzer.type);const e=new Set,a=await this.analyzer.fileHelper.getJSON("app.json");a.plugins&&Object.keys(a.plugins).forEach(t=>{const s=a.plugins[t].provider;this.graph.modules.find(e=>{var a,i;return(null===(a=e.usePlugins)||void 0===a?void 0:a.has(t))||(null===(i=e.usePlugins)||void 0===i?void 0:i.has(s))})||e.add(s)});const t=a.subpackages||a.subPackages;return t&&t.forEach(a=>{const t=a.root;a.plugins&&Object.keys(a.plugins).forEach(s=>{const i=a.plugins[s].provider;this.graph.modules.find(e=>{var a,r;return e.path.startsWith(t)&&((null===(a=e.usePlugins)||void 0===a?void 0:a.has(s))||(null===(r=e.usePlugins)||void 0===r?void 0:r.has(i)))})||e.add(i)})}),Array.from(e)}async checkUnusedComponents(){const e=this.graph.modules.filter(e=>"Page"===e.type||"Component"===e.type||"MainPackage"===e.type||"SubPackage"===e.type),a=[],t=new Set;await Promise.all(e.map(async e=>{let s={};try{s=await this.analyzer.fileHelper.getJSON(e.path)||{}}catch(e){}const i=e=>!!s.componentPlaceholder&&Object.values(s.componentPlaceholder).includes(e),r=a=>{var t;const s=e.findChild("Wxml");return!!s&&(!!(null===(t=s.useTags)||void 0===t?void 0:t.has(a))||!!s.findChildren("Wxml").find(e=>{var t;return null===(t=e.useTags)||void 0===t?void 0:t.has(a)}))},n=Array.from(e.deps).filter(e=>"Component"===e.type);for(const s of n){("MainPackage"===e.type||"SubPackage"===e.type||r(s.name)||(o=s.name,l=void 0,null===(l=e.useTags)||void 0===l?void 0:l.has(o))||i(s.name))&&s.module?t.add(s.module):a.push({page:e.path,tag:s.name,path:s.path||void 0})}var o,l}));return this.graph.modules.filter(e=>"Component"===e.type&&!t.has(e)).map(e=>e.path)}get graph(){return this.analyzer.graph}getSubpackageRoots(){if(this.subpackageRoots)return this.subpackageRoots;const e=this.analyzer.graph.modules.find(e=>"MainPackage"===e.type).findChildren("SubPackage");return this.subpackageRoots=e.map(e=>e.path),this.subpackageRoots}isLocateInMainPackage(e){return!this.getSubpackageRoots().find(a=>e.path.startsWith(a))}caculateFilesSize(e){return e.reduce((e,a)=>{const t=this.analyzer.fileHelper.stat(a);return(null==t?void 0:t.size)&&(e+=t.size),e},0)}caculateResourceFileSize(e){var a,t;let s=0;return null===(t=null===(a=this.analyzer.serialize())||void 0===a?void 0:a.files)||void 0===t||t.forEach(a=>{e.includes(a.ext)&&(s+=a.size)}),s}caculatePackageSize(){var e,a;const t={__APP__:0};return null===(a=null===(e=this.analyzer.serialize())||void 0===e?void 0:e.files)||void 0===a||a.forEach(e=>{e.subPackage?(void 0===t[e.subPackage]&&(t[e.subPackage]=0),t[e.subPackage]+=e.size):t.__APP__+=e.size}),t}collectCompsFiles(e){return e.map(e=>{const a=[e.path];return e.deps.forEach(e=>{var t;"Component"!==e.type&&e.module&&a.push(null===(t=e.module)||void 0===t?void 0:t.path)}),a}).reduce((e,a)=>e.concat(a),[])}}exports.CodeDenpendencyQualityChecker=CodeDenpendencyQualityChecker;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default={version:1639968213754,checkList:[{name:"PACKAGE_SIZE_LIMIT",enabled:!0,desc:"主包尺寸(不包含插件)应小于 %s M",descEn:"Main package size (without plugins) should be less than %s M",limit:1.5,docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",level:2,title:"主包大小",titleEn:"Main Package Size",typeName:"主包",typeNameEn:"Main Package"},{name:"JS_COMPRESS_OPEN",enabled:!0,desc:"对JS文件进行压缩",descEn:"JS compression is not turned on",docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",level:3,title:"JS文件",titleEn:"JS Files",typeName:"代码压缩",typeNameEn:"Code Compress"},{name:"WXML_COMPRESS_OPEN",enabled:!0,desc:"对WXML文件进行压缩",descEn:"WXML compression is not turned on",level:3,docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",title:"WXML文件",titleEn:"WXML Files",typeName:"代码压缩",typeNameEn:"Code Compress"},{name:"WXSS_COMPRESS_OPEN",enabled:!0,desc:"对WXSS文件进行压缩",descEn:"WXSS compression is not turned on",level:3,title:"WXSS文件",titleEn:"WXSS Files",docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",typeName:"代码压缩",typeNameEn:"Code Compress"},{name:"LAZYCODE_LOADING_OPEN",enabled:!0,desc:"启用组件按需注入",descEn:"LazyCodeLoading is not turned on",level:2,docURL:"https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html#%E7%94%A8%E6%97%B6%E6%B3%A8%E5%85%A5",title:"组件",titleEn:"Components",typeName:"代码包",typeNameEn:"Code Package"},{name:"PLUGIN_OVER_SIZE",enabled:!0,desc:"不建议引用过大插件(大小超过 %s K)",descEn:"Reference plugin size exceeds %s K",level:1,limit:200,docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",title:"插件",titleEn:"Plugins",typeName:"代码包",typeNameEn:"Code Package"},{name:"IMAGE_AND_AUDIO_LIMIT",enabled:!0,desc:"图片和音频资源大小应不超过 %s K",descEn:"Picture and audio resources size exceeds %s K",limit:200,level:2,docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",title:"图片和音频资源",titleEn:"Image and Audio Resources",typeName:"代码包",typeNameEn:"Code Package"},{name:"CONTAINS_OTHER_PKG_JS",enabled:!0,desc:"主包内不应存在主包未使用的JS文件 %s",descEn:"The main package has JS that is only dependent on other sub-packages: %s",level:2,docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",title:"JS文件",titleEn:"JS Files",typeName:"主包",typeNameEn:"Main Package"},{name:"CONTAINS_OTHER_PKG_COMPONENTS",enabled:!0,desc:"主包内不应存在主包未使用的组件 %s",descEn:"The main package has components that are only dependent on other sub-packages: %s",level:2,docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",title:"组件",titleEn:"Components",typeName:"主包",typeNameEn:"Main Package"},{name:"CONTAINS_UNUSED_PLUGINS",enabled:!0,desc:"不应存在无使用的插件 %s",descEn:"There are unused plugins: %s",level:3,handlerText:"建议去除",handlerTextEn:"Recommended to remove",title:"插件",titleEn:"Plugins",docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",typeName:"无使用或无依赖文件",typeNameEn:"No Use or Dependency Files"},{name:"CONTAINS_UNUSED_COMPONENTS",enabled:!0,desc:"不应存在无使用的组件 %s",descEn:"There are unused components: %s",level:3,handlerText:"建议去除",handlerTextEn:"Recommended to remove",docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",title:"组件",titleEn:"Components",typeName:"无使用或无依赖文件",typeNameEn:"No Use or Dependency Files"},{name:"CONTAINS_UNUSED_CODES",enabled:!0,desc:"不应存在无依赖文件",descEn:"No dependency files should exist",level:3,handlerText:"点击查看",handlerTextEn:"Click to check",title:"代码文件",titleEn:"Code Files",docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",typeName:"无使用或无依赖文件",typeNameEn:"No Use or Dependency Files"},{name:"CONTAINS_APPSECRET",enabled:!0,desc:"代码中不应存在 AppSecret 敏感信息",descEn:"No AppSecret string in code",level:1,handlerText:"点击查看",handlerTextEn:"Click to check",title:"AppSecret",titleEn:"AppSecret",docURL:"https://developers.weixin.qq.com/community/develop/doc/00040e5a0846706e893dcc24256009",typeName:"敏感信息",typeNameEn:"Sensitive Information"}],regList:{IMAGE_AND_AUDIO_LIMIT:[".jpg",".jpeg",".png",".svg",".webp",".gif",".flac",".m4a",".ogg",".ape",".amr",".wma",".wav",".mp3",".mp4",".aac",".aiff",".caf"]}};
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),ci=tslib_1.__importStar(require("./index")),yargs_1=tslib_1.__importDefault(require("yargs")),log_1=tslib_1.__importDefault(require("./utils/log"));async function run(){let e;function o(o){return{command:o,describe:o+" commands",builder:a=>a.usage(`Usage: $0 cloud ${o} <command>`).command({command:"upload",describe:"upload files",builder:e=>e.options({env:{alias:"e",desc:"env id",string:!0,demandOption:!0},path:{alias:"p",desc:"path to the local folder",string:!0,demandOption:!0},remotePath:{alias:"rp",desc:"path to the remote folder",string:!0,demandOption:!0},concurrency:{alias:"c",desc:"concurrenct upload file count",number:!0,default:5,demandOption:!0}}).group(["env","path","remotePath"],"Options:"),handler:a=>e=e=>ci.cloud["storage"===o?"uploadStorage":"uploadStaticStorage"]({project:e,env:a.env,path:a.path,remotePath:a.remotePath})}),handler:()=>{}}}const a=yargs_1.default.usage("Usage: miniprogram-ci <command> [options]").command("$0","",a=>{a.command({command:"preview",describe:"preview project and get a preview qrcode",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"upload",describe:"upload project",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"get-compiled-result",describe:"get local compiled result, which will be uploaded to the server",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}).options("save-path",{alias:"sp",describe:"save path",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"pack-npm",describe:"pack npm modules for miniprogram",builder:e=>e.demandOption("appid").demandOption("project-path").demandOption("private-key-path"),handler:()=>{}}).command({command:"get-dev-source-map",describe:"get source map of last upload version",builder:e=>e.demandOption("appid").demandOption("project-path").demandOption("private-key-path").options("robot",{alias:"r",describe:"the robot user who is uploading the project",string:!0,default:"1",choices:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"],demandOption:!0}).options("source-map-save-path",{describe:"path to save source map zip",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"pack-npm-manually",describe:"pack npm modules with specified node_modules position",builder:e=>e.options({"pack-npm-manually-package-json-path":{desc:"path of node_modules related package.json",string:!0,demandOption:!0},"pack-npm-manually-miniprogram-npm-dist-dir":{desc:"path of target miniprogram_npm position",string:!0,demandOption:!0},ignores:{alias:"i",desc:"ignore files, glob format",array:!0,demandOption:!1}}).group(["pack-npm-manually-package-json-path","pack-npm-manually-miniprogram-npm-dist-dir","ignores"],"Options:"),handler:e=>{(async()=>{const o=await ci.packNpmManually({packageJsonPath:String(e.packNpmManuallyPackageJsonPath),miniprogramNpmDistDir:String(e.packNpmManuallyMiniprogramNpmDistDir),ignores:[]});log_1.default.log("pack npm done, pack result:",o)})()}}).command({command:"cloud",describe:"cloudbase commands",builder:a=>a.usage("Usage: $0 cloud <command>").command({command:"functions",describe:"cloudfunctions commands",builder:o=>o.usage("Usage: $0 cloud functions <command>").command({command:"upload",describe:"upload a cloudfunction",builder:e=>e.options({env:{alias:"e",desc:"env id",string:!0,demandOption:!0},name:{alias:"n",desc:"cloudfunction name",string:!0,demandOption:!0},path:{alias:"p",desc:"path to the folder containing cloudfunction code",string:!0,demandOption:!0},"remote-npm-install":{alias:"rnpm",desc:"if true, node_modules will not be uploaded and NPM dependencies will be installed in the cloud. if false, node_modules will be uploaded.",boolean:!0}}).group(["env","name","path","remote-npm-install"],"Options:"),handler:o=>e=e=>ci.cloud.uploadFunction({project:e,env:o.env,name:o.name,path:o.path,remoteNpmInstall:o["remote-npm-install"]})}),handler:()=>{}}).command(o("storage")).command(o("staticstorage")).command({command:"container",describe:"container commands",builder:o=>o.usage("Usage: $0 cloud container <command>").command({command:"create",describe:"create a version by uploading package",builder:e=>e.options({env:{alias:"e",desc:"env id",string:!0,demandOption:!0},flow:{desc:"flow ratio of this version",number:!0,demandOption:!0},cpu:{desc:"cpu cores of this version",number:!0,demandOption:!0},mem:{desc:"memory gigabytes of this version",number:!0,demandOption:!0},min:{desc:"minimal copies",number:!0,demandOption:!0},max:{desc:"maximum copies",number:!0,demandOption:!0},threshold:{desc:"cpu threshold for auto scaling",number:!0,demandOption:!0},port:{desc:"container listening port for liveness",number:!0,demandOption:!0},service:{desc:"service name",string:!0,demandOption:!0},remark:{desc:"version remark",string:!0},envParams:{desc:"stringified environment parameters Record<string, string>",string:!0,default:"{}"},allowHttp:{desc:"allow direct http request to this version",boolean:!0,default:!1},containerRoot:{alias:"cr",desc:"path to the container folder",string:!0,demandOption:!0},dockerfilePath:{desc:"custom docker file path",string:!0},buildDir:{desc:"build directory",string:!0}}).group(["env","flow","cpu","mem","min","max","threshold","port","service","remark","envParams","allowHttp","containerRoot","dockerfilePath","buildDir"],"Options:"),handler:o=>e=e=>ci.cloud.uploadContainer({project:e,env:o.env,containerRoot:o.containerRoot,version:{flowRatio:o.flow,cpu:o.cpu,mem:o.mem,minNum:o.min,maxNum:o.max,policyType:"cpu",policyThreshold:o.threshold,containerPort:o.port,serverName:o.service,uploadType:"package",buildDir:o.buildDir,envParams:o.envParams,dockerfilePath:o.dockerfilePath,useHttpRoute:o.allowHttp,versionRemark:o.remark}})}),handler:()=>{}}),handler:()=>{}}).options("appid",{describe:"project appid",string:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0}).options("locales",{describe:"set locales",default:"en",string:!0,choices:["en","zh"]}).option("verbose",{alias:"v",description:"run with verbose logging",default:!0,boolean:!0}).options("proxy",{describe:"proxy url",default:"",string:!0}).options("project-type",{alias:"pt",describe:"project type",string:!0,default:"miniProgram",choices:["miniProgram","miniGame","miniProgramPlugin","miniGamePlugin"]}).options("project-ignores",{alias:"pi",describe:"project ignores",array:!0}).options("upload-description",{alias:"ud",describe:"the uploaded code version description",string:!0}).options("upload-version",{alias:"uv",describe:"the uploaded code version description",string:!0,demandOption:process.argv.includes("preview")||process.argv.includes("upload")&&!process.argv.includes("cloud")}).options("threads",{describe:"the number indicates how many threads will be created for compile the source files",number:!0,default:0,demandOption:process.argv.includes("preview")||process.argv.includes("upload")&&!process.argv.includes("cloud")}).options("use-cos",{describe:"enable uploading code-package through the async way, which is more stable than the direct way",boolean:!0,default:!1,demandOption:process.argv.includes("preview")||process.argv.includes("upload")&&!process.argv.includes("cloud")}).options("robot",{alias:"r",describe:"the robot user who is uploading the project",string:!0,default:"1",choices:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"]}).options("enable-es6",{describe:"enable transform from es6 to es5",default:!1,boolean:!0}).options("enable-es7",{describe:"enable transform from es7 to es5",default:!1,boolean:!0}).options("enable-autoprefixwxss",{describe:"enable autoprefixwxss",default:!1,boolean:!0}).options("enable-minify-wxss",{describe:"enable minify wxss",default:!1,boolean:!0}).options("enable-minify-wxml",{describe:"enable minify wxml",default:!1,boolean:!0}).options("enable-minify-js",{describe:"enable minify js",default:!1,boolean:!0}).options("enable-minify",{describe:"enable minify js/wxml/wxss",default:!1,boolean:!0}).options("enable-code-protect",{describe:"enable code protect",default:!1,boolean:!0}).options("enable-qrcode",{describe:"enable generate weapp qrcode",default:!1,boolean:!0}).options("qrcode-format",{describe:"format of output qrcode",default:"terminal",string:!0,choices:["base64","image","terminal"]}).options("qrcode-output-dest",{describe:"destination of output qrcode",string:!0}).options("preview-page-path",{describe:"preview with page path",string:!0}).options("preview-search-query",{describe:'preview with query, Tips: "&" should be "\\&" in command line',string:!0}).options("scene",{describe:"preview with scene, about scene: https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html",string:!0})},e=>e).help().argv;if(a.help&&(yargs_1.default.showHelp(),process.exit(0)),a.proxy&&ci.proxy(a.proxy),ci.setLocale(a.locales),a._&&!a._.includes("pack-npm-manually")){const o=new ci.Project({appid:a.appid,projectPath:a.projectPath,privateKeyPath:a.privateKeyPath,type:a.projectType,ignores:a.projectIgnores});if(e)await e(o);else if(a._.includes("upload"))await ci.upload({project:o,setting:{es6:a.enableEs6,es7:a.enableEs7,minify:a.enableMinify,autoPrefixWXSS:a.enableHijack,minifyWXML:a.enableMinify||a.enableMinifyWxml,minifyWXSS:a.enableMinify||a.enableMinifyWxss,minifyJS:a.enableMinify||a.enableMinifyJs,codeProtect:a.enableCodeProtect},threads:a.threads,version:a.uploadVersion,desc:a.uploadDescription,robot:a.robot,onProgressUpdate:e=>{a.verbose&&log_1.default.log(""+e)}});else if(a._.includes("preview")){let e=a.scene;e&&(e=parseInt(e,10)),await ci.preview({project:o,setting:{es6:a.enableEs6,es7:a.enableEs7,minify:a.enableMinify,autoPrefixWXSS:a.enableHijack,minifyWXML:a.enableMinify||a.enableMinifyWxml,minifyWXSS:a.enableMinify||a.enableMinifyWxss,minifyJS:a.enableMinify||a.enableMinifyJs,codeProtect:a.enableCodeProtect},threads:a.threads,version:a.uploadVersion,desc:a.uploadDescription,robot:a.robot,pagePath:a.previewPagePath,searchQuery:a.previewSearchQuery,scene:e,onProgressUpdate:e=>{a.verbose&&log_1.default.log(""+e)},qrcodeFormat:a.qrcodeFormat,qrcodeOutputDest:a.qrcodeOutputDest})}else if(a._.includes("get-compiled-result")){let e=a.scene;e&&(e=parseInt(e,10)),await ci.getCompiledResult({project:o,setting:{es6:a.enableEs6,es7:a.enableEs7,minify:a.enableMinify,autoPrefixWXSS:a.enableHijack,minifyWXML:a.enableMinify||a.enableMinify,minifyWXSS:a.enableMinify||a.enableMinifyWxss,minifyJS:a.enableMinify||a.enableMinifyJs,codeProtect:a.enableCodeProtect},threads:a.threads,version:a.uploadVersion,desc:a.uploadDescription,robot:a.robot,pagePath:a.previewPagePath,searchQuery:a.previewSearchQuery,scene:e,onProgressUpdate:e=>{a.verbose&&log_1.default.log(""+e)},qrcodeFormat:a.qrcodeFormat,qrcodeOutputDest:a.qrcodeOutputDest},a.savePath)}else if(a._.includes("pack-npm")){const e=await ci.packNpm(o,{ignores:a.packNpmIgnores,reporter:e=>{a.verbose&&console.log(e)}})||[];e.length&&(log_1.default.log("Pack npm warning:"),log_1.default.log(e.map((e,o)=>`${o+1}. ${e.msg}\n \t> code: ${e.code}\n \t@ ${e.jsPath}:${e.startLine}-${e.endLine}`).join("---------------\n")))}else a._.includes("get-dev-source-map")&&(await ci.getDevSourceMap({project:o,robot:parseInt(a.robot,10),sourceMapSavePath:a.sourceMapSavePath}),log_1.default.info(`save sourcemap.zip to ${a.sourceMapSavePath} successfully`))}}run().catch(e=>{console.error(e),process.exit(1)});
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),ci=tslib_1.__importStar(require("./index")),yargs_1=tslib_1.__importDefault(require("yargs")),log_1=tslib_1.__importDefault(require("./utils/log")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),path_1=tslib_1.__importDefault(require("path"));async function run(){let e;function a(a){return{command:a,describe:a+" commands",builder:i=>i.usage(`Usage: $0 cloud ${a} <command>`).command({command:"upload",describe:"upload files",builder:e=>e.options({env:{alias:"e",desc:"env id",string:!0,demandOption:!0},path:{alias:"p",desc:"path to the local folder",string:!0,demandOption:!0},remotePath:{alias:"rp",desc:"path to the remote folder",string:!0,demandOption:!0},concurrency:{alias:"c",desc:"concurrenct upload file count",number:!0,default:5,demandOption:!0}}).group(["env","path","remotePath"],"Options:"),handler:i=>e=e=>ci.cloud["storage"===a?"uploadStorage":"uploadStaticStorage"]({project:e,env:i.env,path:i.path,remotePath:i.remotePath})}),handler:()=>{}}}const i=yargs_1.default.usage("Usage: miniprogram-ci <command> [options]").command("$0","",i=>{i.command({command:"preview",describe:"preview project and get a preview qrcode",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"upload",describe:"upload project",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"get-compiled-result",describe:"get local compiled result, which will be uploaded to the server",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}).options("save-path",{alias:"sp",describe:"save path",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"check-code-quality",describe:"check code quality and get a json report",builder:e=>e.options("appid",{describe:"project appid",string:!0,demandOption:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0,demandOption:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0,demandOption:!0}).options("save-path",{alias:"sp",describe:"save path",string:!0,demandOption:!1}),handler:()=>{}}).command({command:"pack-npm",describe:"pack npm modules for miniprogram",builder:e=>e.demandOption("appid").demandOption("project-path").demandOption("private-key-path"),handler:()=>{}}).command({command:"get-dev-source-map",describe:"get source map of last upload version",builder:e=>e.demandOption("appid").demandOption("project-path").demandOption("private-key-path").options("robot",{alias:"r",describe:"the robot user who is uploading the project",string:!0,default:"1",choices:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"],demandOption:!0}).options("source-map-save-path",{describe:"path to save source map zip",string:!0,demandOption:!0}),handler:()=>{}}).command({command:"pack-npm-manually",describe:"pack npm modules with specified node_modules position",builder:e=>e.options({"pack-npm-manually-package-json-path":{desc:"path of node_modules related package.json",string:!0,demandOption:!0},"pack-npm-manually-miniprogram-npm-dist-dir":{desc:"path of target miniprogram_npm position",string:!0,demandOption:!0},ignores:{alias:"i",desc:"ignore files, glob format",array:!0,demandOption:!1}}).group(["pack-npm-manually-package-json-path","pack-npm-manually-miniprogram-npm-dist-dir","ignores"],"Options:"),handler:e=>{(async()=>{const a=await ci.packNpmManually({packageJsonPath:String(e.packNpmManuallyPackageJsonPath),miniprogramNpmDistDir:String(e.packNpmManuallyMiniprogramNpmDistDir),ignores:[]});log_1.default.log("pack npm done, pack result:",a)})()}}).command({command:"cloud",describe:"cloudbase commands",builder:i=>i.usage("Usage: $0 cloud <command>").command({command:"functions",describe:"cloudfunctions commands",builder:a=>a.usage("Usage: $0 cloud functions <command>").command({command:"upload",describe:"upload a cloudfunction",builder:e=>e.options({env:{alias:"e",desc:"env id",string:!0,demandOption:!0},name:{alias:"n",desc:"cloudfunction name",string:!0,demandOption:!0},path:{alias:"p",desc:"path to the folder containing cloudfunction code",string:!0,demandOption:!0},"remote-npm-install":{alias:"rnpm",desc:"if true, node_modules will not be uploaded and NPM dependencies will be installed in the cloud. if false, node_modules will be uploaded.",boolean:!0}}).group(["env","name","path","remote-npm-install"],"Options:"),handler:a=>e=e=>ci.cloud.uploadFunction({project:e,env:a.env,name:a.name,path:a.path,remoteNpmInstall:a["remote-npm-install"]})}),handler:()=>{}}).command(a("storage")).command(a("staticstorage")).command({command:"container",describe:"container commands",builder:a=>a.usage("Usage: $0 cloud container <command>").command({command:"create",describe:"create a version by uploading package",builder:e=>e.options({env:{alias:"e",desc:"env id",string:!0,demandOption:!0},flow:{desc:"flow ratio of this version",number:!0,demandOption:!0},cpu:{desc:"cpu cores of this version",number:!0,demandOption:!0},mem:{desc:"memory gigabytes of this version",number:!0,demandOption:!0},min:{desc:"minimal copies",number:!0,demandOption:!0},max:{desc:"maximum copies",number:!0,demandOption:!0},threshold:{desc:"cpu threshold for auto scaling",number:!0,demandOption:!0},port:{desc:"container listening port for liveness",number:!0,demandOption:!0},service:{desc:"service name",string:!0,demandOption:!0},remark:{desc:"version remark",string:!0},envParams:{desc:"stringified environment parameters Record<string, string>",string:!0,default:"{}"},allowHttp:{desc:"allow direct http request to this version",boolean:!0,default:!1},containerRoot:{alias:"cr",desc:"path to the container folder",string:!0,demandOption:!0},dockerfilePath:{desc:"custom docker file path",string:!0},buildDir:{desc:"build directory",string:!0}}).group(["env","flow","cpu","mem","min","max","threshold","port","service","remark","envParams","allowHttp","containerRoot","dockerfilePath","buildDir"],"Options:"),handler:a=>e=e=>ci.cloud.uploadContainer({project:e,env:a.env,containerRoot:a.containerRoot,version:{flowRatio:a.flow,cpu:a.cpu,mem:a.mem,minNum:a.min,maxNum:a.max,policyType:"cpu",policyThreshold:a.threshold,containerPort:a.port,serverName:a.service,uploadType:"package",buildDir:a.buildDir,envParams:a.envParams,dockerfilePath:a.dockerfilePath,useHttpRoute:a.allowHttp,versionRemark:a.remark}})}),handler:()=>{}}),handler:()=>{}}).options("appid",{describe:"project appid",string:!0}).options("project-path",{alias:"pp",describe:"project path",string:!0}).options("private-key-path",{alias:"pkp",describe:"private key path",string:!0}).options("locales",{describe:"set locales",default:"en",string:!0,choices:["en","zh"]}).option("verbose",{alias:"v",description:"run with verbose logging",default:!0,boolean:!0}).options("proxy",{describe:"proxy url",default:"",string:!0}).options("project-type",{alias:"pt",describe:"project type",string:!0,default:"miniProgram",choices:["miniProgram","miniGame","miniProgramPlugin","miniGamePlugin"]}).options("project-ignores",{alias:"pi",describe:"project ignores",array:!0}).options("upload-description",{alias:"ud",describe:"the uploaded code version description",string:!0}).options("upload-version",{alias:"uv",describe:"the uploaded code version description",string:!0,demandOption:process.argv.includes("preview")||process.argv.includes("upload")&&!process.argv.includes("cloud")}).options("threads",{describe:"the number indicates how many threads will be created for compile the source files",number:!0,default:0,demandOption:process.argv.includes("preview")||process.argv.includes("upload")&&!process.argv.includes("cloud")}).options("use-cos",{describe:"enable uploading code-package through the async way, which is more stable than the direct way",boolean:!0,default:!1,demandOption:process.argv.includes("preview")||process.argv.includes("upload")&&!process.argv.includes("cloud")}).options("robot",{alias:"r",describe:"the robot user who is uploading the project",string:!0,default:"1",choices:["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"]}).options("enable-es6",{describe:"enable transform from es6 to es5",default:!1,boolean:!0}).options("enable-es7",{describe:"enable transform from es7 to es5",default:!1,boolean:!0}).options("enable-autoprefixwxss",{describe:"enable autoprefixwxss",default:!1,boolean:!0}).options("enable-minify-wxss",{describe:"enable minify wxss",default:!1,boolean:!0}).options("enable-minify-wxml",{describe:"enable minify wxml",default:!1,boolean:!0}).options("enable-minify-js",{describe:"enable minify js",default:!1,boolean:!0}).options("enable-minify",{describe:"enable minify js/wxml/wxss",default:!1,boolean:!0}).options("enable-code-protect",{describe:"enable code protect",default:!1,boolean:!0}).options("enable-qrcode",{describe:"enable generate weapp qrcode",default:!1,boolean:!0}).options("qrcode-format",{describe:"format of output qrcode",default:"terminal",string:!0,choices:["base64","image","terminal"]}).options("qrcode-output-dest",{describe:"destination of output qrcode",string:!0}).options("preview-page-path",{describe:"preview with page path",string:!0}).options("preview-search-query",{describe:'preview with query, Tips: "&" should be "\\&" in command line',string:!0}).options("scene",{describe:"preview with scene, about scene: https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html",string:!0})},e=>e).help().argv;if(i.help&&(yargs_1.default.showHelp(),process.exit(0)),i.proxy&&ci.proxy(i.proxy),ci.setLocale(i.locales),i._&&!i._.includes("pack-npm-manually")){const a=new ci.Project({appid:i.appid,projectPath:i.projectPath,privateKeyPath:i.privateKeyPath,type:i.projectType,ignores:i.projectIgnores});if(e)await e(a);else if(i._.includes("upload"))await ci.upload({project:a,setting:{es6:i.enableEs6,es7:i.enableEs7,minify:i.enableMinify,autoPrefixWXSS:i.enableHijack,minifyWXML:i.enableMinify||i.enableMinifyWxml,minifyWXSS:i.enableMinify||i.enableMinifyWxss,minifyJS:i.enableMinify||i.enableMinifyJs,codeProtect:i.enableCodeProtect},threads:i.threads,version:i.uploadVersion,desc:i.uploadDescription,robot:i.robot,onProgressUpdate:e=>{i.verbose&&log_1.default.log(""+e)}});else if(i._.includes("preview")){let e=i.scene;e&&(e=parseInt(e,10)),await ci.preview({project:a,setting:{es6:i.enableEs6,es7:i.enableEs7,minify:i.enableMinify,autoPrefixWXSS:i.enableHijack,minifyWXML:i.enableMinify||i.enableMinifyWxml,minifyWXSS:i.enableMinify||i.enableMinifyWxss,minifyJS:i.enableMinify||i.enableMinifyJs,codeProtect:i.enableCodeProtect},threads:i.threads,version:i.uploadVersion,desc:i.uploadDescription,robot:i.robot,pagePath:i.previewPagePath,searchQuery:i.previewSearchQuery,scene:e,onProgressUpdate:e=>{i.verbose&&log_1.default.log(""+e)},qrcodeFormat:i.qrcodeFormat,qrcodeOutputDest:i.qrcodeOutputDest})}else if(i._.includes("get-compiled-result")){let e=i.scene;e&&(e=parseInt(e,10)),await ci.getCompiledResult({project:a,setting:{es6:i.enableEs6,es7:i.enableEs7,minify:i.enableMinify,autoPrefixWXSS:i.enableHijack,minifyWXML:i.enableMinify||i.enableMinify,minifyWXSS:i.enableMinify||i.enableMinifyWxss,minifyJS:i.enableMinify||i.enableMinifyJs,codeProtect:i.enableCodeProtect},threads:i.threads,version:i.uploadVersion,desc:i.uploadDescription,robot:i.robot,pagePath:i.previewPagePath,searchQuery:i.previewSearchQuery,scene:e,onProgressUpdate:e=>{i.verbose&&log_1.default.log(""+e)},qrcodeFormat:i.qrcodeFormat,qrcodeOutputDest:i.qrcodeOutputDest},i.savePath)}else if(i._.includes("pack-npm")){const e=await ci.packNpm(a,{ignores:i.packNpmIgnores,reporter:e=>{i.verbose&&console.log(e)}})||[];e.length&&(log_1.default.log("Pack npm warning:"),log_1.default.log(e.map((e,a)=>`${a+1}. ${e.msg}\n \t> code: ${e.code}\n \t@ ${e.jsPath}:${e.startLine}-${e.endLine}`).join("---------------\n")))}else if(i._.includes("get-dev-source-map"))await ci.getDevSourceMap({project:a,robot:parseInt(i.robot,10),sourceMapSavePath:i.sourceMapSavePath}),log_1.default.info(`save sourcemap.zip to ${i.sourceMapSavePath} successfully`);else if(i._.includes("check-code-quality")){const e=await ci.checkCodeQuality(a);i.savePath?(fs_extra_1.default.ensureDirSync(path_1.default.dirname(i.savePath)),fs_extra_1.default.writeFileSync(i.savePath,JSON.stringify(e)),log_1.default.info(`save json format report to ${i.savePath} successfully`)):console.log(e)}}}run().catch(e=>{console.error(e),process.exit(1)});
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="1.9.
|
|
2
|
+
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="1.9.13",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(_){_.miniProgram="miniProgram",_.miniProgramPlugin="miniProgramPlugin",_.miniGame="miniGame",_.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}};
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkRequiredPrivateInfos=exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../../../config"),common_1=require("../common"),common_2=require("../../../utils/common"),tools_1=require("../../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(e,o,t){const{miniprogramRoot:a,project:c,filePath:n}=e;c.stat(a,o+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,o+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(e){const{inputJSON:o,mode:t}=e;let a=""+e.filePath;o.themeLocation&&(a+=` or ${o.themeLocation}["${t}"]`);const c=[],{window:n}=o;n&&(void 0!==n.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&((0,tools_1.isHexColor)(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:a}))}function checkTabbar(e){const{project:o,miniprogramRoot:t,inputJSON:a,mode:c}=e;let n=""+e.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=o.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n}),r.list.length>s.MaxTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(s.MaxTabbarCount),filePath:n});for(let e=0;e<r.list.length;e++){const a=r.list[e],{pagePath:c}=a;if((0,common_2.checkPath)({value:c,tips:`["tabBar"]["list"][${e}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(e));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"."));const i=r.list.slice(0,e).findIndex(e=>e.pagePath===c);i>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(e,i));const f=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${e}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${e}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"selectedIconPath",path:a.selectedIconPath})),f.forEach(a=>{const c=o.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${e}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${e}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([e,a.name,s.MaxTabbarIconSize]));const n=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(n)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([e,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:n})}function checkWorkers(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a});const i=(0,tools_1.getWorkersPath)(n);(0,common_2.checkPath)({value:i,tips:r,filePath:a});const s=o.stat(t,i);s&&s.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),"string"==typeof c.workers?c.workers=(0,tools_1.normalizePath)(c.workers+"/"):c.workers.path=(0,tools_1.normalizePath)(c.workers.path+"/")}function checkOpenLocationPagePath(e){const{filePath:o,inputJSON:t}=e,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:c,filePath:o}),checkPageExist(e,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=e=>{const{filePath:o,inputJSON:t}=e,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:o}),c[n]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:o}),c[n]=!0,checkPageExist(e,n,r)}};function checkSitemapLocation(e){const{filePath:o,inputJSON:t}=e,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=e,r='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:r,filePath:o});const i=c.stat(n,a);i&&!i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:o});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:o});const s=c.getFile(n,a),l=(0,common_2.checkUTF8)(s,a),f=(0,common_1.checkJSONFormat)(l,a),h=(0,schemaValidate_1.schemaValidate)("sitemap",f);if(h.error.length){const e=h.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_2.throwError)({msg:e,filePath:a})}}function checkSubpackages(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=o.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},f={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],h=`${n}[${i}]`;if((0,common_2.checkPath)({value:s.root,tips:`${n}[${i}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(f[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(h,f[s.name],"name"));continue}f[s.name]=h}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(h,l[s.root],"root"));continue}l[s.root]=h;const _=o.stat(t,s.root);if(!_){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!_.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const p={};for(let o=0,t=s.pages.length;o<t;o++){const t=s.pages[o];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${o}]`,filePath:a});const c=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,t));p[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(p[c]=!0,checkPageExist(e,c,`${n}[${i}]["pages"][${o}]`))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a});for(let e=0;e<c.subPackages.length;e++){const o=c.subPackages[e];let t=-1;const a="/"+o.root;c.subPackages.forEach((o,c)=>{if(c!==e&&o.root){const e="/"+o.root;0===a.indexOf(e)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${e}]["root"]`))}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}}function checkPlugins(e){const{filePath:o,inputJSON:t,project:a}=e,c=[],n=t.plugins||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(e,o){var t;const{appid:n}=a,i=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(i||"dev"!==e.version)if(i)"dev"===e.version&&e.provider!==n&&e.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["provider"]',`"${null!==(t=r.pluginAppid)&&void 0!==t?t:n}"`)):e.provider===n&&"dev"!==e.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["version"]','"dev"'));else{if("dev"===e.version||"latest"===e.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(e.version)||/^dev-[A-Za-z0-9]+$/.test(e.version))return!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(o+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const e in n){i(n[e],`["plugins"]["${e}"]`)}t.subPackages&&t.subPackages.forEach((e,o)=>{if(!e.plugins)return;const t=`["subPackages"][${o}]`;for(const o in e.plugins){i(e.plugins[o],`${t}["plugins"]["${o}"]`)}}),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkNavigateToMiniProgramAppIdList(e){const{filePath:o,inputJSON:t,project:a}=e,c=[];if(t.navigateToMiniProgramAppIdList){const e=a.attrSync(),{appType:o=config_1.APP_TYPE.NORMAL,setting:n}=e;if(o!==config_1.APP_TYPE.NATIVE){const e=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>e&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',e))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkFunctionalPages(e){const{inputJSON:o}=e;if(o.functionalPages&&"object"!==(0,tools_1.getType)(o.functionalPages)){const e='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';o.__warning__?o.__warning__=`${o.__warning__}\n${e}`:o.__warning__=e}}function checkPreloadRule(e,o){const{inputJSON:t,filePath:a}=e,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};o.forEach(e=>{i[e.root]=!0,l[e.path]=!0,e.name&&(s[e.name]=!0)});for(const e in c){if(!l[e]&&!e.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const o=c[e];for(let t=0,a=o.packages.length;t<a;t++){let a=o.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(e,o){const{inputJSON:t,filePath:a}=e,{entryPagePath:c}=t;if(!c)return;(0,common_2.checkPath)({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const e of o)if(e.path===c){n=!0;break}n||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(e){const{filePath:o,inputJSON:t}=e,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.list.length;e++){const o=a.list[e],{pagePath:t}=o;c.indexOf(t)<0&&n.push(`["tabBar"][${e}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPageIsInSubpkg(e){const{filePath:o,inputJSON:t}=e,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.length;e++){const o=a[e];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(o.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${e}]`]))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPluginIsInSubPkg(e){const{filePath:o,inputJSON:t}=e,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const e in a){const o=a[e],t=`["plugins"]["${e}"]`;n[o.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${e}"]`,n[o.provider].tips,"provider")):n[o.provider]=r[e]={provider:o.provider,version:o.version,alias:e,tips:t}}if(c)for(let e=0;e<c.length;e++){const o=c[e];if(o.plugins)for(const t in o.plugins){const a=`["subPackages"][${e}]["plugins"]`,c=o.plugins[t];n[c.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`${a}["${t}"]`,n[c.provider].tips,"provider")):r[t]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${t}"]`,r[t].tips)):n[c.provider]=r[t]={provider:c.provider,version:c.version,alias:c,tips:a}}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:o})}function checkComponentPath(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(e){const o=e.inputJSON;if(!o.entranceDeclare||!o.entranceDeclare.locationMessage)return;let t=o.pages||[];o.subpackages&&(t=t.concat(o.subpackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t)),o.subPackages&&(t=t.concat(o.subPackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t));const a=[],c=o.entranceDeclare.locationMessage.path;void 0===c?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):t.includes(c)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([c||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:e.filePath})}function getAppJSONVariableDecalearProperty(e){const{windowPropertWhiteList:o,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(e.window)&&(c=c.concat(Object.keys(e.window).filter(e=>o.includes(e)).map(o=>({property:`["window"]["${o}"]`,value:e.window[o]})).filter(e=>e.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(e.tabBar)&&(c=c.concat(Object.keys(e.tabBar).filter(e=>t.includes(e)).map(o=>({property:`["tabBar"]["${o}"]`,value:e.tabBar[o]})).filter(e=>e.value.startsWith("@"))),Array.isArray(e.tabBar.list)&&e.tabBar.list.forEach((o,t)=>{c=c.concat(Object.keys(o).filter(e=>a.includes(e)).map(o=>({property:`["tabBar"]["list"][${t}]["${o}"]`,value:e.tabBar.list[t][o]})).filter(e=>e.value.startsWith("@")))})),c}function checkOpenDataContext(e,o){const{project:t,miniprogramRoot:a,filePath:c}=e,{openDataContext:n}=o;if(void 0===n)return;(0,common_2.checkPath)({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:c});const i=path_1.default.posix.join(n,"./index.js"),s=t.stat(a,i);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),o.openDataContext=(0,tools_1.normalizePath)(n+"/")}function checkRenderer(e){const{filePath:o,inputJSON:t}=e,{renderer:a,lazyCodeLoading:c}=t;"skyline"===a&&"requiredComponents"!==c&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:o})}function checkResolveAlias(e){const{filePath:o,inputJSON:t}=e,{resolveAlias:a}=t;if(a){const e=e=>e.includes("//");for(const t in a)(e(t)||e(a[t]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(t,a[t]),filePath:o}),a[t].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[t]),filePath:o}),t.endsWith("/*")&&a[t].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(t,a[t]),filePath:o})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;const detailLocationApis={getLocation:!0,onLocationChange:!0,startLocationUpdate:!0,startLocationUpdateBackground:!0};function checkRequiredPrivateInfos(e){const{filePath:o,inputJSON:t}=e,{requiredPrivateInfos:a}=t;if(a){if(a.indexOf("getFuzzyLocation")>=0){const e=[];for(let o=0;o<a.length;o++){const t=a[o];detailLocationApis[t]&&e.push(`'${t}'`)}e.length>0&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE.format("'getFuzzyLocation'",e.join("、")),filePath:o})}}}exports.checkRequiredPrivateInfos=checkRequiredPrivateInfos;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkRequiredPrivateInfos=exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../../../config"),common_1=require("../common"),common_2=require("../../../utils/common"),tools_1=require("../../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(o,e,t){const{miniprogramRoot:a,project:c,filePath:n}=o;c.stat(a,e+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,e+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,e+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,e+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(o){const{inputJSON:e,mode:t}=o;let a=""+o.filePath;e.themeLocation&&(a+=` or ${e.themeLocation}["${t}"]`);const c=[],{window:n}=e;n&&(void 0!==n.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&((0,tools_1.isHexColor)(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:a}))}function checkTabbar(o){const{project:e,miniprogramRoot:t,inputJSON:a,mode:c}=o;let n=""+o.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=e.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n});const f=r.custom?s.MaxCustomTabbarCount:s.MaxTabbarCount;r.list.length>f&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(f),filePath:n});for(let o=0;o<r.list.length;o++){const a=r.list[o],{pagePath:c}=a;if((0,common_2.checkPath)({value:c,tips:`["tabBar"]["list"][${o}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(o));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"."));const i=r.list.slice(0,o).findIndex(o=>o.pagePath===c);i>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(o,i));const f=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${o}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${o}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"selectedIconPath",path:a.selectedIconPath})),f.forEach(a=>{const c=e.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${o}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${o}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([o,a.name,s.MaxTabbarIconSize]));const n=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(n)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([o,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:n})}function checkWorkers(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a});const i=(0,tools_1.getWorkersPath)(n);(0,common_2.checkPath)({value:i,tips:r,filePath:a});const s=e.stat(t,i);s&&s.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),"string"==typeof c.workers?c.workers=(0,tools_1.normalizePath)(c.workers+"/"):c.workers.path=(0,tools_1.normalizePath)(c.workers.path+"/")}function checkOpenLocationPagePath(o){const{filePath:e,inputJSON:t}=o,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:c,filePath:e}),checkPageExist(o,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=o=>{const{filePath:e,inputJSON:t}=o,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:e}),c[n]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:e}),c[n]=!0,checkPageExist(o,n,r)}};function checkSitemapLocation(o){const{filePath:e,inputJSON:t}=o,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=o,r='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:r,filePath:e});const i=c.stat(n,a);i&&!i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:e});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:e});const s=c.getFile(n,a),l=(0,common_2.checkUTF8)(s,a),f=(0,common_1.checkJSONFormat)(l,a),h=(0,schemaValidate_1.schemaValidate)("sitemap",f);if(h.error.length){const o=h.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_2.throwError)({msg:o,filePath:a})}}function checkSubpackages(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=e.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},f={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],h=`${n}[${i}]`;if((0,common_2.checkPath)({value:s.root,tips:`${n}[${i}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(f[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(h,f[s.name],"name"));continue}f[s.name]=h}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(h,l[s.root],"root"));continue}l[s.root]=h;const _=e.stat(t,s.root);if(!_){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!_.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const p={};for(let e=0,t=s.pages.length;e<t;e++){const t=s.pages[e];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${e}]`,filePath:a});const c=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,t));p[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(p[c]=!0,checkPageExist(o,c,`${n}[${i}]["pages"][${e}]`))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a});for(let o=0;o<c.subPackages.length;o++){const e=c.subPackages[o];let t=-1;const a="/"+e.root;c.subPackages.forEach((e,c)=>{if(c!==o&&e.root){const o="/"+e.root;0===a.indexOf(o)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${o}]["root"]`))}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}}function checkPlugins(o){const{filePath:e,inputJSON:t,project:a}=o,c=[],n=t.plugins||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(o,e){var t;const{appid:n}=a,i=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(i||"dev"!==o.version)if(i)"dev"===o.version&&o.provider!==n&&o.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(e+'["provider"]',`"${null!==(t=r.pluginAppid)&&void 0!==t?t:n}"`)):o.provider===n&&"dev"!==o.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(e+'["version"]','"dev"'));else{if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(e+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const o in n){i(n[o],`["plugins"]["${o}"]`)}t.subPackages&&t.subPackages.forEach((o,e)=>{if(!o.plugins)return;const t=`["subPackages"][${e}]`;for(const e in o.plugins){i(o.plugins[e],`${t}["plugins"]["${e}"]`)}}),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:e})}function checkNavigateToMiniProgramAppIdList(o){const{filePath:e,inputJSON:t,project:a}=o,c=[];if(t.navigateToMiniProgramAppIdList){const o=a.attrSync(),{appType:e=config_1.APP_TYPE.NORMAL,setting:n}=o;if(e!==config_1.APP_TYPE.NATIVE){const o=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>o&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',o))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:e})}function checkFunctionalPages(o){const{inputJSON:e}=o;if(e.functionalPages&&"object"!==(0,tools_1.getType)(e.functionalPages)){const o='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';e.__warning__?e.__warning__=`${e.__warning__}\n${o}`:e.__warning__=o}}function checkPreloadRule(o,e){const{inputJSON:t,filePath:a}=o,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};e.forEach(o=>{i[o.root]=!0,l[o.path]=!0,o.name&&(s[o.name]=!0)});for(const o in c){if(!l[o]&&!o.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const e=c[o];for(let t=0,a=e.packages.length;t<a;t++){let a=e.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(o,e){const{inputJSON:t,filePath:a}=o,{entryPagePath:c}=t;if(!c)return;(0,common_2.checkPath)({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const o of e)if(o.path===c){n=!0;break}n||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(o){const{filePath:e,inputJSON:t}=o,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let o=0;o<a.list.length;o++){const e=a.list[o],{pagePath:t}=e;c.indexOf(t)<0&&n.push(`["tabBar"][${o}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:e})}function checkMainPkgPageIsInSubpkg(o){const{filePath:e,inputJSON:t}=o,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let o=0;o<a.length;o++){const e=a[o];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(e.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${o}]`]))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:e})}function checkMainPkgPluginIsInSubPkg(o){const{filePath:e,inputJSON:t}=o,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const o in a){const e=a[o],t=`["plugins"]["${o}"]`;n[e.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,n[e.provider].tips,"provider")):n[e.provider]=r[o]={provider:e.provider,version:e.version,alias:o,tips:t}}if(c)for(let o=0;o<c.length;o++){const e=c[o];if(e.plugins)for(const t in e.plugins){const a=`["subPackages"][${o}]["plugins"]`,c=e.plugins[t];n[c.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`${a}["${t}"]`,n[c.provider].tips,"provider")):r[t]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${t}"]`,r[t].tips)):n[c.provider]=r[t]={provider:c.provider,version:c.version,alias:c,tips:a}}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:e})}function checkComponentPath(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o;(0,common_1.checkComponentPath)({project:e,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(o){const e=o.inputJSON;if(!e.entranceDeclare||!e.entranceDeclare.locationMessage)return;let t=e.pages||[];e.subpackages&&(t=t.concat(e.subpackages.map(o=>o.pages.map(e=>o.root+e))),t=lodash_1.default.flattenDeep(t)),e.subPackages&&(t=t.concat(e.subPackages.map(o=>o.pages.map(e=>o.root+e))),t=lodash_1.default.flattenDeep(t));const a=[],c=e.entranceDeclare.locationMessage.path;void 0===c?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):t.includes(c)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([c||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:o.filePath})}function getAppJSONVariableDecalearProperty(o){const{windowPropertWhiteList:e,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(o.window)&&(c=c.concat(Object.keys(o.window).filter(o=>e.includes(o)).map(e=>({property:`["window"]["${e}"]`,value:o.window[e]})).filter(o=>o.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(o.tabBar)&&(c=c.concat(Object.keys(o.tabBar).filter(o=>t.includes(o)).map(e=>({property:`["tabBar"]["${e}"]`,value:o.tabBar[e]})).filter(o=>o.value.startsWith("@"))),Array.isArray(o.tabBar.list)&&o.tabBar.list.forEach((e,t)=>{c=c.concat(Object.keys(e).filter(o=>a.includes(o)).map(e=>({property:`["tabBar"]["list"][${t}]["${e}"]`,value:o.tabBar.list[t][e]})).filter(o=>o.value.startsWith("@")))})),c}function checkOpenDataContext(o,e){const{project:t,miniprogramRoot:a,filePath:c}=o,{openDataContext:n}=e;if(void 0===n)return;(0,common_2.checkPath)({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:c});const i=path_1.default.posix.join(n,"./index.js"),s=t.stat(a,i);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),e.openDataContext=(0,tools_1.normalizePath)(n+"/")}function checkRenderer(o){const{filePath:e,inputJSON:t}=o,{renderer:a,lazyCodeLoading:c}=t;"skyline"===a&&"requiredComponents"!==c&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:e})}function checkResolveAlias(o){const{filePath:e,inputJSON:t}=o,{resolveAlias:a}=t;if(a){const o=o=>o.includes("//");for(const t in a)(o(t)||o(a[t]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(t,a[t]),filePath:e}),a[t].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[t]),filePath:e}),t.endsWith("/*")&&a[t].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(t,a[t]),filePath:e})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;const detailLocationApis={getLocation:!0,onLocationChange:!0,startLocationUpdate:!0,startLocationUpdateBackground:!0};function checkRequiredPrivateInfos(o){const{filePath:e,inputJSON:t}=o,{requiredPrivateInfos:a}=t;if(a){if(a.indexOf("getFuzzyLocation")>=0){const o=[];for(let e=0;e<a.length;e++){const t=a[e];detailLocationApis[t]&&o.push(`'${t}'`)}o.length>0&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE.format("'getFuzzyLocation'",o.join("、")),filePath:e})}}}exports.checkRequiredPrivateInfos=checkRequiredPrivateInfos;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../utils/tools"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),process_1=require("process"),config_1=require("../../config"),isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;function info(...e){}function log(...e){isDevtools&&console.log.apply(console,e)}function error(...e){isDevtools&&console.error.apply(console,e)}function isAttrEqual(e,t){return"object"==typeof e&&"object"==typeof t&&(!(!e||!t)&&(e.platform===t.platform&&e.appType===t.appType&&e.gameApp===t.gameApp&&e.isSandbox===t.isSandbox&&e.released===t.released&&(e.setting.MaxCodeSize===t.setting.MaxCodeSize&&e.setting.MaxSubpackageSubCodeSize===t.setting.MaxSubpackageSubCodeSize&&e.setting.MaxSubpackageFullCodeSize===t.setting.MaxSubpackageFullCodeSize&&e.setting.NavigateMiniprogramLimit===t.setting.NavigateMiniprogramLimit&&e.setting.MaxSubPackageLimit===t.setting.MaxSubPackageLimit&&e.setting.MinTabbarCount===t.setting.MinTabbarCount&&e.setting.MaxTabbarCount===t.setting.MaxTabbarCount&&e.setting.MaxTabbarIconSize===t.setting.MaxTabbarIconSize)))}function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}class ReactiveProject{constructor(e){if(this.fileBoxs=new Map,this.statBoxs=new Map,this.resetFileChangeListener=()=>{},this.project=e,e.onFileChange){const t=e.onFileChange;e.onFileChange=(i,o)=>{t.call(e,i,o),this.onFileChange(i,o)},this.resetFileChangeListener=()=>{e.onFileChange=t}}this.miniprogramRootBox=(0,reactivity_1.ref)(e.miniprogramRoot),this.pluginRootBox=(0,reactivity_1.ref)(e.pluginRoot),this.appidBox=(0,reactivity_1.ref)(e.appid),this.typeBox=(0,reactivity_1.ref)(e.type),this.attrBox=(0,reactivity_1.ref)(config_1.DefaultProjectAttr)}release(){this.resetFileChangeListener(),log("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getFileList(e,t){return this.project.getFileList(e,t)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}updateFiles(){throw new Error("Method updateFiles not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const e=await this.project.attr();return isAttrEqual(e,this.attrBox.value)||(this.attrBox.value=e),new Promise(e=>{setTimeout(e,0)})}onFileChange(e,t){if("change"===e){const e=this.fileBoxs.get(t);if(e){const i=this.project.getFile("",t);e.value&&0===i.compare(e.value)||(e.value=i)}}else if("unlink"===e){const e=this.fileBoxs.get(t);e&&(this.fileBoxs.delete(t),e.value=void 0);const i=this.statBoxs.get(t);if(i){const e=this.project.stat("",t);(0,lodash_1.isEqual)(e,i.value)||(i.value=e)}}else if("unlinkDir"===e){const e=t+"/";let i=Array.from(this.fileBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.fileBoxs.get(t);this.fileBoxs.delete(t),e.value=void 0}i=Array.from(this.statBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.statBoxs.get(t);void 0!==e.value&&(this.statBoxs.delete(t),e.value=void 0)}}else if("add"===e||"addDir"===e){const e=this.statBoxs.get(t);if(e){const i=this.project.stat("",t);(0,lodash_1.isEqual)(i,e.value)||(e.value=i)}}}getFile(e,t){const i=this.getTargetPath(e,t),o=this.fileBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.getFile(e,t));return this.fileBoxs.set(i,o),o.value}}stat(e,t){const i=this.getTargetPath(e,t),o=this.statBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.stat(e,t));return this.statBoxs.set(i,o),o.value}}attrSync(){return this.attrBox.value}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(e){this.miniprogramRootBox.value=e,this.project.miniprogramRoot=e}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(e){this.pluginRootBox.value=e,this.project.pluginRoot=e}getTargetPath(e,t){return(0,tools_1.normalizePath)(path_1.default.posix.join(e,t)).replace(/\/$/,"").replace(/^\//,"")}}exports.ReactiveProject=ReactiveProject;const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}exports.tryToGetReactiveProject=tryToGetReactiveProject;let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const t=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,t.forEach(e=>{e()})}finally{info(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}}))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){log("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...i){let o=this.jsonComputeds.get(e);if(!o){o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o);let
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../utils/tools"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),process_1=require("process"),config_1=require("../../config"),isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;function info(...e){}function log(...e){isDevtools&&console.log.apply(console,e)}function error(...e){isDevtools&&console.error.apply(console,e)}function isAttrEqual(e,t){return"object"==typeof e&&"object"==typeof t&&(!(!e||!t)&&(e.platform===t.platform&&e.appType===t.appType&&e.gameApp===t.gameApp&&e.isSandbox===t.isSandbox&&e.released===t.released&&(e.setting.MaxCodeSize===t.setting.MaxCodeSize&&e.setting.MaxSubpackageSubCodeSize===t.setting.MaxSubpackageSubCodeSize&&e.setting.MaxSubpackageFullCodeSize===t.setting.MaxSubpackageFullCodeSize&&e.setting.NavigateMiniprogramLimit===t.setting.NavigateMiniprogramLimit&&e.setting.MaxSubPackageLimit===t.setting.MaxSubPackageLimit&&e.setting.MinTabbarCount===t.setting.MinTabbarCount&&e.setting.MaxTabbarCount===t.setting.MaxTabbarCount&&e.setting.MaxCustomTabbarCount===t.setting.MaxCustomTabbarCount&&e.setting.MaxTabbarIconSize===t.setting.MaxTabbarIconSize)))}function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}class ReactiveProject{constructor(e){if(this.fileBoxs=new Map,this.statBoxs=new Map,this.resetFileChangeListener=()=>{},this.project=e,e.onFileChange){const t=e.onFileChange;e.onFileChange=(i,o)=>{t.call(e,i,o),this.onFileChange(i,o)},this.resetFileChangeListener=()=>{e.onFileChange=t}}this.miniprogramRootBox=(0,reactivity_1.ref)(e.miniprogramRoot),this.pluginRootBox=(0,reactivity_1.ref)(e.pluginRoot),this.appidBox=(0,reactivity_1.ref)(e.appid),this.typeBox=(0,reactivity_1.ref)(e.type),this.attrBox=(0,reactivity_1.ref)(config_1.DefaultProjectAttr)}release(){this.resetFileChangeListener(),log("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getFileList(e,t){return this.project.getFileList(e,t)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}updateFiles(){throw new Error("Method updateFiles not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const e=await this.project.attr();return isAttrEqual(e,this.attrBox.value)||(this.attrBox.value=e),new Promise(e=>{setTimeout(e,0)})}onFileChange(e,t){if("change"===e){const e=this.fileBoxs.get(t);if(e){const i=this.project.getFile("",t);e.value&&0===i.compare(e.value)||(e.value=i)}}else if("unlink"===e){const e=this.fileBoxs.get(t);e&&(this.fileBoxs.delete(t),e.value=void 0);const i=this.statBoxs.get(t);if(i){const e=this.project.stat("",t);(0,lodash_1.isEqual)(e,i.value)||(i.value=e)}}else if("unlinkDir"===e){const e=t+"/";let i=Array.from(this.fileBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.fileBoxs.get(t);this.fileBoxs.delete(t),e.value=void 0}i=Array.from(this.statBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.statBoxs.get(t);void 0!==e.value&&(this.statBoxs.delete(t),e.value=void 0)}}else if("add"===e||"addDir"===e){const e=this.statBoxs.get(t);if(e){const i=this.project.stat("",t);(0,lodash_1.isEqual)(i,e.value)||(e.value=i)}}}getFile(e,t){const i=this.getTargetPath(e,t),o=this.fileBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.getFile(e,t));return this.fileBoxs.set(i,o),o.value}}stat(e,t){const i=this.getTargetPath(e,t),o=this.statBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.stat(e,t));return this.statBoxs.set(i,o),o.value}}attrSync(){return this.attrBox.value}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(e){this.miniprogramRootBox.value=e,this.project.miniprogramRoot=e}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(e){this.pluginRootBox.value=e,this.project.pluginRoot=e}getTargetPath(e,t){return(0,tools_1.normalizePath)(path_1.default.posix.join(e,t)).replace(/\/$/,"").replace(/^\//,"")}}exports.ReactiveProject=ReactiveProject;const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}exports.tryToGetReactiveProject=tryToGetReactiveProject;let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const t=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,t.forEach(e=>{e()})}finally{info(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}}))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){log("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...i){let o=this.jsonComputeds.get(e);if(!o){o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o);let a=void 0;a=(0,reactivity_1.effect)(()=>{try{info(`[reactiveCache] ${e} start to update`);const a=t.call(null,this.project,...i);(0,lodash_1.isEqual)(a,o.value)?info(`[reactiveCache] ${e} update finish, value no change`):(o.value=makeReadonly(a),info(`[reactiveCache] ${e} update finish, new value: `,o.value))}catch(t){o.value=t instanceof Error?t:new Error(t.toString()),log(`[reactiveCache] update ${e} failed: `,t)}},{scheduler(){a&&a.active&&runInNextTick(a)}})}const{value:a}=o;if(a instanceof Error)throw a;return a}static setOriginGetPageJSON(e){this.originGetPageJSON=e}static setOriginCheckPageJSON(e){this.originCheckPageJSON=e}getPageJSON(e,t){let i=this.pageComputeds.get(t.pagePath);i||(i={checked:(0,reactivity_1.ref)(void 0),compiled:(0,reactivity_1.ref)(void 0)},this.pageComputeds.set(t.pagePath,i));const o=i[e];if(void 0===o.value){let i=void 0;i=(0,reactivity_1.effect)(()=>{try{info(`[reactiveCache] start to update ${e} ${t.pagePath}`);const i="compiled"===e?ReactiveJSONCompiler.originGetPageJSON(this.project,t):ReactiveJSONCompiler.originCheckPageJSON(this.project,t);o.value=makeReadonly(i),info(`[reactiveCache] update finish ${e} ${t.pagePath}`)}catch(i){o.value=i instanceof Error?i:new Error(i.toString()),log(`[reactiveCache] update ${e} ${t.pagePath} failed: `,i)}},{scheduler(){i&&i.active&&(0,process_1.nextTick)(i)}})}const a=o.value;if(a instanceof Error)throw a;return a}}exports.ReactiveJSONCompiler=ReactiveJSONCompiler;const reactiveJSONCompilerMap=new Map;function tryToGetReactiveJSONCompiler(e){let t=reactiveJSONCompilerMap.get(e.projectPath);return t||(t=new ReactiveJSONCompiler(e),reactiveJSONCompilerMap.set(e.projectPath,t),t)}function wrapCompileJSONFunc(e,t){return function(i,...o){i instanceof ReactiveProject||(i=tryToGetReactiveProject(i));return tryToGetReactiveJSONCompiler(i).registerOrGet(e,t,...o)}}function cleanReactiveCache(){reactiveProjectMap.forEach(e=>{e.release()}),reactiveProjectMap.clear(),reactiveJSONCompilerMap.forEach(e=>{e.release()}),reactiveJSONCompilerMap.clear()}exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),config_1=require("../../../config"),call_func_1=require("./call_func"),log_1=tslib_1.__importDefault(require("../../../utils/log")),babel_helper_1=require("../../../utils/babel_helper"),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6_transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjs_after_wrap"),MAX_CODE_LENGTH=
|
|
1
|
+
"use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),config_1=require("../../../config"),call_func_1=require("./call_func"),log_1=tslib_1.__importDefault(require("../../../utils/log")),babel_helper_1=require("../../../utils/babel_helper"),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6_transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjs_after_wrap"),MAX_CODE_LENGTH=2048e3;async function tryGetInputSourceMap(e,r){try{const t=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),s=path_1.default.posix.dirname(r),o=path_1.default.posix.basename(r);let i;if(null==t?void 0:t[1])if(/\.js\.map$/.test(t[1]))i=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(s,t[1]),"utf-8");else{const e=t[1].split("base64,")[1];i=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(s,o+".map");fs_1.default.existsSync(e)&&(i=await(0,call_func_1.call)("readFileAsync",e,"utf-8"))}if(i){const e=(0,jsonParse_1.jsonParse)(i);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,r),e}}catch(e){log_1.default.log(`try to get input sourcemap of ${r} catch error ${e}`)}}const insertSourcesContent=async(e,r)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const t=e.sourcesContent;try{const t=path_1.default.posix.dirname(r),s=[],o=e.sources;for(const e of o){const r=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(t,e),"utf-8");s.push(r)}e.sourcesContent=s}catch(r){e.sourcesContent=t}}};async function compileJS(e){const{code:r,filePath:t,projectPath:s,setting:o,babelRoot:i="@babel/runtime",root:a="",babelIgnore:n=[]}=e,{es7:l,es6:c,disableUseStrict:u,compileWorklet:p}=o,f="string"==typeof r?r:(0,tools_1.bufferToUtf8String)(Buffer.from(r)),_=path_1.default.posix.join(a,t),m=o.minify||o.minifyJS;if(void 0===f)return{error:{code:config_1.FILE_NOT_UTF8,path:_,message:locales_1.default.config.FILE_NOT_UTF8.format(_)}};const b=f.length>=2048e3;let d=!1;l&&(d=(0,babel_helper_1.isIgnore)(n,t));const h=await tryGetInputSourceMap(f,path_1.default.posix.join(s,a,t));if(b||d)return{error:null,isLargeFile:b,isBabelIgnore:d,map:"object"==typeof h?JSON.stringify(h):h,code:f,helpers:[]};let g=f,j=h,y=[];if(l){const e=await require("../../js/enhance")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:h});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}else if(c){const e=require("../../js/es6_transform")({code:f,filePath:t,inputSourceMap:h});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map}else if(p){if(f.includes('"worklet"')||f.includes("'worklet'")){const e=await require("../../js/workletCompile")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:h});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}}if(m){if(!c&&!l){const e=require("../../js/minifyjs_after_wrap")({filePath:t,code:g,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}else{const e=require("../../js/minifyjs")({filePath:t,code:g,useTerser:!!l,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}}if("string"!=typeof j)try{(null==j?void 0:j.sourcesContent)&&(j.sourcesContent=j.sourcesContent.map(e=>e.replace(/\r\n/g,"\n"))),j=JSON.stringify(j)}catch(e){j=""}else j=j.replace(/\\r\\n/g,"\\n");return{error:null,isLargeFile:b,isBabelIgnore:d,map:j,code:g.replace(/\r\n/g,"\n"),helpers:y||[]}}module.exports=compileJS;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.workletVersion=exports.getWhiteExtList=exports.analyseCode=exports.getLatestVersion=exports.uploadJsServer=exports.cloud=exports.getDevSourceMap=exports.proxy=exports.packNpmManually=exports.packNpm=exports.getCompiledResult=exports.preview=exports.upload=exports.Project=void 0;const tslib_1=require("tslib"),project_1=require("./ci/project");Object.defineProperty(exports,"Project",{enumerable:!0,get:function(){return project_1.Project}});const upload_1=require("./ci/upload"),preview_1=require("./ci/preview"),getDevSourceMap_1=require("./ci/getDevSourceMap"),packnpm_1=require("./core/npm/packnpm");Object.defineProperty(exports,"packNpm",{enumerable:!0,get:function(){return packnpm_1.packNpm}}),Object.defineProperty(exports,"packNpmManually",{enumerable:!0,get:function(){return packnpm_1.packNpmManually}});const request_1=require("./utils/request");Object.defineProperty(exports,"proxy",{enumerable:!0,get:function(){return request_1.setCiProxy}});const uploadFunction_1=require("./cloud/uploadFunction"),createTimeTrigger_1=require("./cloud/createTimeTrigger"),uploadContainer_1=require("./cloud/uploadContainer"),uploadFile_1=require("./cloud/uploadFile"),report_1=require("./utils/report"),jsserver_1=require("./ci/jsserver");Object.defineProperty(exports,"uploadJsServer",{enumerable:!0,get:function(){return jsserver_1.uploadJsServer}});const code_analyse_1=require("./ci/code-analyse");Object.defineProperty(exports,"analyseCode",{enumerable:!0,get:function(){return code_analyse_1.analyseCode}});const getCompiledResult_1=require("./ci/getCompiledResult");Object.defineProperty(exports,"getCompiledResult",{enumerable:!0,get:function(){return getCompiledResult_1.getCompiledResult}});const getLatestVersion_1=require("./ci/getLatestVersion");Object.defineProperty(exports,"getLatestVersion",{enumerable:!0,get:function(){return getLatestVersion_1.getLatestVersion}});const white_ext_list_1=require("./utils/white_ext_list");Object.defineProperty(exports,"getWhiteExtList",{enumerable:!0,get:function(){return white_ext_list_1.getWhiteExtList}}),exports.upload=(0,report_1.wrapReport)("upload",upload_1.upload),exports.preview=(0,report_1.wrapReport)("preview",preview_1.preview),exports.getDevSourceMap=(0,report_1.wrapReport)("getDevSourceMap",getDevSourceMap_1.getDevSourceMap),exports.cloud={uploadFunction:uploadFunction_1.uploadFunction,createTimeTrigger:createTimeTrigger_1.createTimeTrigger,uploadStaticStorage:e=>(0,uploadFile_1.uploadFiles)(e,"staticstorage"),uploadStorage:e=>(0,uploadFile_1.uploadFiles)(e,"storage"),uploadContainer:uploadContainer_1.uploadContainer},tslib_1.__exportStar(require("./core"),exports),tslib_1.__exportStar(require("./summer"),exports),exports.workletVersion=require("./utils/babel_plugin_worklet").version;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.workletVersion=exports.getWhiteExtList=exports.checkCodeQuality=exports.analyseCode=exports.getLatestVersion=exports.uploadJsServer=exports.cloud=exports.getDevSourceMap=exports.proxy=exports.packNpmManually=exports.packNpm=exports.getCompiledResult=exports.preview=exports.upload=exports.Project=void 0;const tslib_1=require("tslib"),project_1=require("./ci/project");Object.defineProperty(exports,"Project",{enumerable:!0,get:function(){return project_1.Project}});const upload_1=require("./ci/upload"),preview_1=require("./ci/preview"),getDevSourceMap_1=require("./ci/getDevSourceMap"),packnpm_1=require("./core/npm/packnpm");Object.defineProperty(exports,"packNpm",{enumerable:!0,get:function(){return packnpm_1.packNpm}}),Object.defineProperty(exports,"packNpmManually",{enumerable:!0,get:function(){return packnpm_1.packNpmManually}});const request_1=require("./utils/request");Object.defineProperty(exports,"proxy",{enumerable:!0,get:function(){return request_1.setCiProxy}});const uploadFunction_1=require("./cloud/uploadFunction"),createTimeTrigger_1=require("./cloud/createTimeTrigger"),uploadContainer_1=require("./cloud/uploadContainer"),uploadFile_1=require("./cloud/uploadFile"),report_1=require("./utils/report"),jsserver_1=require("./ci/jsserver");Object.defineProperty(exports,"uploadJsServer",{enumerable:!0,get:function(){return jsserver_1.uploadJsServer}});const code_analyse_1=require("./ci/code-analyse");Object.defineProperty(exports,"analyseCode",{enumerable:!0,get:function(){return code_analyse_1.analyseCode}});const getCompiledResult_1=require("./ci/getCompiledResult");Object.defineProperty(exports,"getCompiledResult",{enumerable:!0,get:function(){return getCompiledResult_1.getCompiledResult}});const getLatestVersion_1=require("./ci/getLatestVersion");Object.defineProperty(exports,"getLatestVersion",{enumerable:!0,get:function(){return getLatestVersion_1.getLatestVersion}});const white_ext_list_1=require("./utils/white_ext_list");Object.defineProperty(exports,"getWhiteExtList",{enumerable:!0,get:function(){return white_ext_list_1.getWhiteExtList}});const checkCodeQuality_1=require("./ci/checkCodeQuality");Object.defineProperty(exports,"checkCodeQuality",{enumerable:!0,get:function(){return checkCodeQuality_1.checkCodeQuality}}),exports.upload=(0,report_1.wrapReport)("upload",upload_1.upload),exports.preview=(0,report_1.wrapReport)("preview",preview_1.preview),exports.getDevSourceMap=(0,report_1.wrapReport)("getDevSourceMap",getDevSourceMap_1.getDevSourceMap),exports.cloud={uploadFunction:uploadFunction_1.uploadFunction,createTimeTrigger:createTimeTrigger_1.createTimeTrigger,uploadStaticStorage:e=>(0,uploadFile_1.uploadFiles)(e,"staticstorage"),uploadStorage:e=>(0,uploadFile_1.uploadFiles)(e,"storage"),uploadContainer:uploadContainer_1.uploadContainer},tslib_1.__exportStar(require("./core"),exports),tslib_1.__exportStar(require("./summer"),exports),exports.workletVersion=require("./utils/babel_plugin_worklet").version;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/manifest.json
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");tslib_1.__exportStar(require("./miniprogram-json/index"),exports);
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckOption=void 0;const tslib_1=require("tslib");tslib_1.__exportStar(require("./miniprogram-json/index"),exports),exports.CheckOption={PACKAGE_SIZE_LIMIT:1,IMAGE_AND_AUDIO_LIMIT:2,CONTAINS_OTHER_PKG_JS:3,CONTAINS_OTHER_PKG_COMPONENTS:4,CONTAINS_OTHER_PKG_PLUGINS:5,JS_COMPRESS_OPEN:6,WXML_COMPRESS_OPEN:7,WXSS_COMPRESS_OPEN:8,CONTAINS_UNUSED_PLUGINS:9,PLUGIN_OVER_SIZE:10,USE_EXTENDLIB_WITHOUT_DEFINED:11,LAZYCODE_LOADING_OPEN:12,CONTAINS_UNUSED_COMPONENTS:13,CONTAINS_UNUSED_CODES:14,CONTAINS_APPSECRET:14};
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),en_1=tslib_1.__importDefault(require("./en")),zh_1=tslib_1.__importDefault(require("./zh")),systemLocale="$SYSTEM",supportedLocales=["zh","en"];let locale="en";const toSupportedLocale=e=>("$SYSTEM"===e&&"zh_CN"===(e=navigator.language)&&(e="zh"),supportedLocales.find(t=>e.toLowerCase().includes(t))||"zh"),setLocale=e=>{locale=toSupportedLocale(e)};exports.default={get config(){return"en"===locale?en_1.default:zh_1.default},setLocale:setLocale};
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),en_1=tslib_1.__importDefault(require("./en")),zh_1=tslib_1.__importDefault(require("./zh")),systemLocale="$SYSTEM",supportedLocales=["zh","en"];let locale="en";const toSupportedLocale=e=>("$SYSTEM"===e&&"zh_CN"===(e=navigator.language)&&(e="zh"),supportedLocales.find(t=>e.toLowerCase().includes(t))||"zh"),getLocale=()=>locale,setLocale=e=>{locale=toSupportedLocale(e)};exports.default={get config(){return"en"===locale?en_1.default:zh_1.default},setLocale:setLocale,getLocale:getLocale};
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/package.json
CHANGED