miniprogram-ci 1.8.0 → 1.8.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/dist/@types/ci/cos-upload.d.ts +1 -3
- package/dist/@types/config.d.ts +1 -1
- package/dist/@types/core/json/app/checkAppFields.d.ts +1 -0
- package/dist/@types/core/worker_thread/task/minifywxml.d.ts +26 -1
- package/dist/@types/summer/devtool.d.ts +5 -0
- package/dist/@types/summer/graph/basegraph.d.ts +2 -0
- package/dist/@types/summer/plugins/minifywxml.d.ts +5 -0
- package/dist/@types/summer/summer.d.ts +1 -0
- package/dist/@types/summer/types.d.ts +12 -3
- package/dist/@types/types/miniprogram-json/app.d.ts +3 -0
- package/dist/@types/utils/babel_plugin_worklet.d.ts +34 -0
- package/dist/@types/utils/locales/locales.d.ts +3 -0
- package/dist/@types/utils/locales/zh.d.ts +3 -0
- package/dist/@types/vendor/code-analyse/index.d.ts +58 -1
- package/dist/ci/code-analyse.js +1 -1
- package/dist/ci/cos-upload.js +1 -1
- package/dist/ci/getCompiledResult.js +1 -1
- package/dist/ci/getDevSourceMap.js +1 -1
- package/dist/ci/getLatestVersion.js +1 -1
- package/dist/ci/jsserver.js +1 -1
- package/dist/ci/preview.js +1 -1
- package/dist/ci/project.js +1 -1
- package/dist/ci/projectattr.js +1 -1
- package/dist/ci/upload.js +1 -1
- package/dist/ci/utils/packfile.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/cloud/cloudapi.js +1 -1
- package/dist/cloud/createTimeTrigger.js +1 -1
- package/dist/cloud/uploadContainer.js +1 -1
- package/dist/cloud/uploadFile.js +1 -1
- package/dist/cloud/uploadFunction.js +1 -1
- package/dist/cloud/utils.js +1 -1
- package/dist/config.js +1 -1
- package/dist/core/compile/common.js +1 -1
- package/dist/core/compile/game.js +1 -1
- package/dist/core/compile/game_plugin.js +1 -1
- package/dist/core/compile/handler/js.js +1 -1
- package/dist/core/compile/handler/mpjson.js +1 -1
- package/dist/core/compile/handler/wxml.js +1 -1
- package/dist/core/compile/handler/wxss.js +1 -1
- package/dist/core/compile/index.js +1 -1
- package/dist/core/compile/mini_program.js +1 -1
- package/dist/core/compile/mini_program_plugin.js +1 -1
- package/dist/core/js/enhance.js +1 -1
- package/dist/core/js/index.js +1 -1
- package/dist/core/js/minifyjs.js +1 -1
- package/dist/core/js/minifyjs_after_wrap.js +1 -1
- package/dist/core/json/app/checkAppFields.js +1 -1
- package/dist/core/json/app/getAppJSON.js +1 -1
- package/dist/core/json/app/getExtJSON.js +1 -1
- package/dist/core/json/app/index.js +1 -1
- package/dist/core/json/common.js +1 -1
- package/dist/core/json/game.js +1 -1
- package/dist/core/json/page/checkPageJSON.js +1 -1
- package/dist/core/json/page/getPageJSON.js +1 -1
- package/dist/core/json/plugin/plugin.js +1 -1
- package/dist/core/json/plugin/plugin_page.js +1 -1
- package/dist/core/json/projectWithMockBuffer.js +1 -1
- package/dist/core/json/projectconfig.js +1 -1
- package/dist/core/json/reactiveCache.js +1 -1
- package/dist/core/json/signaturejson.js +1 -1
- package/dist/core/json/sitemap.js +1 -1
- package/dist/core/json/theme.js +1 -1
- package/dist/core/npm/filterdeps.js +1 -1
- package/dist/core/npm/packnpm.js +1 -1
- package/dist/core/protect/file_flatter.js +1 -1
- package/dist/core/protect/uglifyfilenames.js +1 -1
- package/dist/core/validate/validate.js +1 -1
- package/dist/core/worker_thread/childprocess.js +1 -1
- package/dist/core/worker_thread/childprocess_manager.js +1 -1
- package/dist/core/worker_thread/fork.js +1 -1
- package/dist/core/worker_thread/index.js +1 -1
- package/dist/core/worker_thread/task/call_func.js +1 -1
- package/dist/core/worker_thread/task/compilejs.js +1 -1
- package/dist/core/worker_thread/task/compilewxss.js +1 -1
- package/dist/core/worker_thread/task/func.js +1 -1
- package/dist/core/worker_thread/task/index.js +1 -1
- package/dist/core/worker_thread/task/minifywxml.js +1 -1
- package/dist/core/worker_thread/worker.js +1 -1
- package/dist/core/worker_thread/worker_manager.js +1 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest.json +3 -3
- package/dist/schema/dist/index.d.ts +1 -1
- package/dist/summer/ci.js +1 -1
- package/dist/summer/devtool.js +1 -1
- package/dist/summer/entry_process.js +1 -1
- package/dist/summer/graph/appconf.js +1 -1
- package/dist/summer/graph/appgraph.js +1 -1
- package/dist/summer/graph/basegraph.js +1 -1
- package/dist/summer/graph/pluginconf.js +1 -1
- package/dist/summer/graph/plugingraph.js +1 -1
- package/dist/summer/initPlugin.js +1 -1
- package/dist/summer/persist_cache.js +1 -1
- package/dist/summer/plugins/base/es6module.js +1 -1
- package/dist/summer/plugins/base/javascript.js +1 -1
- package/dist/summer/plugins/base/wxss.js +1 -1
- package/dist/summer/plugins/enhance.js +1 -1
- package/dist/summer/plugins/index.js +1 -1
- package/dist/summer/plugins/less.js +1 -1
- package/dist/summer/plugins/minifywxml.js +1 -0
- package/dist/summer/plugins/sass.js +1 -1
- package/dist/summer/plugins/terser.js +1 -1
- package/dist/summer/plugins/typescript.js +1 -1
- package/dist/summer/project.js +1 -1
- package/dist/summer/resolver.js +1 -1
- package/dist/summer/summer.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/miniprogram-json/index.js +1 -1
- package/dist/utils/babel_helper.js +1 -1
- package/dist/utils/babel_plugin_worklet.js +3 -0
- package/dist/utils/common.js +1 -1
- package/dist/utils/error.js +1 -1
- package/dist/utils/fsagent.js +1 -1
- package/dist/utils/glob.js +1 -1
- package/dist/utils/jsonParse.js +1 -1
- package/dist/utils/locales/en.js +1 -1
- package/dist/utils/locales/locales.js +1 -1
- package/dist/utils/locales/zh.js +1 -1
- package/dist/utils/request.js +1 -1
- package/dist/utils/sign.js +1 -1
- package/dist/utils/taskstatus.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/dist/utils/white_ext_list.js +1 -1
- package/dist/vendor/cloud-api/src/apis/apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/cdn/cdn.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/cdn/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/flexdb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/scf.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/ssl/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/ssl/ssl.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/general.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/tcb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/index.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/cdn.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/flexdb.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/scf.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/ssl.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/tcb.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/cdn.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/common.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/flexdb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/scf.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/ssl.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/tcb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/validations.js +1 -1
- package/dist/vendor/code-analyse/index.js +1 -1
- package/dist/vendor/schema/dist/app.js +37 -1
- package/dist/vendor/schema/dist/ext.js +32 -1
- package/dist/vendor/schema/dist/game.js +1 -1
- package/dist/vendor/schema/dist/index.js +2 -1
- package/dist/vendor/schema/dist/page.js +24 -1
- package/dist/vendor/schema/dist/plugin.js +1 -1
- package/dist/vendor/schema/dist/pluginpage.js +1 -1
- package/dist/vendor/schema/dist/projectconfig.js +395 -12
- package/dist/vendor/schema/dist/projectprivateconfig.js +351 -0
- package/dist/vendor/schema/dist/sitemap.js +1 -1
- package/dist/vendor/schema/dist/theme.js +1 -1
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 1.8.25
|
|
2
|
+
- `new` 更新 增强编译支持编译 worklet 函数
|
|
3
|
+
- `fix` 修复 使用编译插件时,也支持 wxml 压缩功能
|
|
4
|
+
## 1.8.18
|
|
5
|
+
- `new` 更新 `analyseCode` 代码依赖分析能力。
|
|
6
|
+
## 1.8.12
|
|
7
|
+
- `new` app.json 配置支持 halfPage
|
|
8
|
+
- `new` 更新 上传时忽略 project.private.config.json 文件
|
|
9
|
+
- `new` 更新 代码包超过 5MB 后,默认通过异步方式上传代码,详情可查看 useCOS 参数
|
|
10
|
+
- `fix` 修复 ts 项目支持 babelSetting ignore 配置
|
|
11
|
+
- `fix` 修复 windows 编译 less 或 sass 文件提示路径出错的 bug [相关反馈](https://developers.weixin.qq.com/community/develop/doc/000ecc927587e0aca69df553851400)
|
|
1
12
|
## 1.6.1
|
|
2
13
|
- `new` 新增 支持编译工具上对应的 Typescript 模板项目。
|
|
3
14
|
- `fix` 更新 wxml压缩逻辑,可通过 minifyWXML 参数开启 wxml 压缩。
|
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ const ci = require('miniprogram-ci')
|
|
|
122
122
|
| onProgressUpdate | function | 否 | 进度更新监听函数 |
|
|
123
123
|
| robot | number | 否 | 指定使用哪一个 ci 机器人,可选值:1 ~ 30 |
|
|
124
124
|
| threads | number | 否 | 指定本地编译过程中开启的线程数 |
|
|
125
|
-
| useCOS | boolean | 否 |
|
|
125
|
+
| useCOS | boolean | 否 | 使用异步方式上传,当代码包大于 5MB 时,默认开启 |
|
|
126
126
|
|
|
127
127
|
#### 返回
|
|
128
128
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IProject } from '../types';
|
|
3
|
-
export declare function uploadByCos(
|
|
4
|
-
[key: string]: string | Buffer;
|
|
5
|
-
}, commitUrl: string, project: IProject, robot: any): Promise<{
|
|
3
|
+
export declare function uploadByCos(gzipBuffer: Buffer, commitUrl: string, project: IProject, robot: any): Promise<{
|
|
6
4
|
fallback: boolean;
|
|
7
5
|
body?: any;
|
|
8
6
|
uploadCOSCostTime?: number;
|
package/dist/@types/config.d.ts
CHANGED
|
@@ -37,4 +37,5 @@ interface IVariableDeclareProperty {
|
|
|
37
37
|
export declare function getAppJSONVariableDecalearProperty(appJSON: AppJSON.IAppJSON): Array<IVariableDeclareProperty>;
|
|
38
38
|
export declare function checkOpenDataContext(options: IInnerAppJSONCheckOptions, appJSON: AppJSON.IAppJSON): void;
|
|
39
39
|
export declare function checkRenderer(options: IInnerAppJSONCheckOptions): void;
|
|
40
|
+
export declare function checkResolveAlias(options: IInnerAppJSONCheckOptions): void;
|
|
40
41
|
export {};
|
|
@@ -7,6 +7,25 @@ interface ICompileData {
|
|
|
7
7
|
setting: MiniProgramCI.ICompileSettings;
|
|
8
8
|
code: Buffer;
|
|
9
9
|
}
|
|
10
|
+
declare enum TokenType {
|
|
11
|
+
ATTR = 0,
|
|
12
|
+
STRING1 = 1,
|
|
13
|
+
STRING2 = 2,
|
|
14
|
+
OTHERS = 3
|
|
15
|
+
}
|
|
16
|
+
declare class Token {
|
|
17
|
+
type: TokenType;
|
|
18
|
+
value: string;
|
|
19
|
+
constructor(type: TokenType, value: string);
|
|
20
|
+
}
|
|
21
|
+
declare class Tokenizer {
|
|
22
|
+
constructor(src: string, path: string);
|
|
23
|
+
generateTokens(output: Array<Token>): number;
|
|
24
|
+
private m_pSrc;
|
|
25
|
+
private path;
|
|
26
|
+
private machine;
|
|
27
|
+
}
|
|
28
|
+
declare function generateWXMLFromTokens(tokens: Array<Token>): string;
|
|
10
29
|
declare function minifyWXML(data: ICompileData): Promise<{
|
|
11
30
|
error: null;
|
|
12
31
|
code: string;
|
|
@@ -18,4 +37,10 @@ declare function minifyWXML(data: ICompileData): Promise<{
|
|
|
18
37
|
};
|
|
19
38
|
code?: undefined;
|
|
20
39
|
}>;
|
|
21
|
-
|
|
40
|
+
declare const _default: {
|
|
41
|
+
minifyWXML: typeof minifyWXML;
|
|
42
|
+
Tokenizer: typeof Tokenizer;
|
|
43
|
+
generateWXMLFromTokens: typeof generateWXMLFromTokens;
|
|
44
|
+
Token: typeof Token;
|
|
45
|
+
};
|
|
46
|
+
export = _default;
|
|
@@ -111,6 +111,10 @@ export interface IPluginConf {
|
|
|
111
111
|
comps: Record<string, any>;
|
|
112
112
|
}
|
|
113
113
|
declare type ISummerPluginConfig = Array<string | [string, SummerPluginOptions]>;
|
|
114
|
+
export declare type IBabelSetting = {
|
|
115
|
+
outputPath?: string;
|
|
116
|
+
ignore?: any[];
|
|
117
|
+
};
|
|
114
118
|
export interface ICompilerOptions {
|
|
115
119
|
appid: string;
|
|
116
120
|
attr: any;
|
|
@@ -118,6 +122,7 @@ export interface ICompilerOptions {
|
|
|
118
122
|
miniprogramRoot: string;
|
|
119
123
|
pluginRoot: string;
|
|
120
124
|
summerPlugins: ISummerPluginConfig;
|
|
125
|
+
babelSetting?: IBabelSetting;
|
|
121
126
|
}
|
|
122
127
|
export declare class SummerCompiler {
|
|
123
128
|
projectPath: string;
|
|
@@ -10,6 +10,7 @@ import PersistCache from '../persist_cache';
|
|
|
10
10
|
declare type GraphType = 'miniprogram' | 'plugin' | 'other';
|
|
11
11
|
export declare type FileInfo = ResolveFileInfo & {
|
|
12
12
|
independentRoot: string;
|
|
13
|
+
isBabelIgnore: boolean;
|
|
13
14
|
};
|
|
14
15
|
export interface IGraphOptions {
|
|
15
16
|
type: GraphType;
|
|
@@ -49,6 +50,7 @@ export declare abstract class BaseGraph {
|
|
|
49
50
|
}>>;
|
|
50
51
|
private compileOther;
|
|
51
52
|
private compileCodeWithoutJSON;
|
|
53
|
+
protected isBabelSettingIgnore(fileInfo: ResolveFileInfo): boolean;
|
|
52
54
|
protected abstract onFileChangeForGraph(type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', path: string): void;
|
|
53
55
|
protected abstract getConf(recorder: Recorder): Promise<IAppConf | IPluginConf>;
|
|
54
56
|
protected abstract getDevCode(recorder: Recorder, options?: IPackageCodeOptions): Promise<CodeFiles>;
|
|
@@ -16,6 +16,7 @@ export declare class SummerCompiler {
|
|
|
16
16
|
proxyProject: any;
|
|
17
17
|
persistCache: PersistCache;
|
|
18
18
|
constructor(project: Project, cachePath: string, options: ICompilerOptions);
|
|
19
|
+
getBabelSetting(): import("./devtool").IBabelSetting | undefined;
|
|
19
20
|
private initPlugins;
|
|
20
21
|
private initAppGraph;
|
|
21
22
|
private initPluginGraph;
|
|
@@ -73,10 +73,19 @@ export declare type AsyncPluginHooks = 'load' | 'transform' | 'optimize' | 'gene
|
|
|
73
73
|
export declare type FirstPluginHooks = 'load' | 'generate';
|
|
74
74
|
export declare type SequentialPluginHooks = 'transform' | 'optimize' | 'compress';
|
|
75
75
|
export declare type ParallelPluginHooks = 'sealed';
|
|
76
|
-
export declare type LoadHook = (this: PluginContext, targetPath: string, sourcePath: string,
|
|
77
|
-
|
|
76
|
+
export declare type LoadHook = (this: PluginContext, targetPath: string, sourcePath: string, options: {
|
|
77
|
+
independentRoot: string;
|
|
78
|
+
isBabelIgnore: boolean;
|
|
79
|
+
}) => Promise<LoadResult> | LoadResult;
|
|
80
|
+
export declare type TransformHook = (this: PluginContext, source: SourceDescription, targetPath: string, sourcePath: string, options: {
|
|
81
|
+
independentRoot: string;
|
|
82
|
+
isBabelIgnore: boolean;
|
|
83
|
+
}) => Promise<SourceDescription> | SourceDescription;
|
|
78
84
|
declare type GenerateResult = GenerateDescription | string | null | undefined;
|
|
79
|
-
export declare type GenerateHook = (this: PluginContext, source: SourceDescription, targetPath: string, sourcePath: string,
|
|
85
|
+
export declare type GenerateHook = (this: PluginContext, source: SourceDescription, targetPath: string, sourcePath: string, options: {
|
|
86
|
+
independentRoot: string;
|
|
87
|
+
isBabelIgnore: boolean;
|
|
88
|
+
}) => Promise<GenerateResult> | GenerateResult;
|
|
80
89
|
export declare type OptimizeHook = (this: PluginContext, codes: Record<string, string>, appConf: IAppConf) => Promise<Record<string, string>>;
|
|
81
90
|
export declare type CompressHook = (this: PluginContext, content: Record<string, string | Buffer>) => Promise<Record<string, string | Buffer>>;
|
|
82
91
|
export declare type SealedHook = (this: PluginContext, content: Record<string, string | Buffer>) => Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const template: any;
|
|
2
|
+
declare const generate: any;
|
|
3
|
+
declare const hash: any;
|
|
4
|
+
declare const transformSync: any;
|
|
5
|
+
declare const traverse: any;
|
|
6
|
+
declare const parse: any;
|
|
7
|
+
declare const buildBindFunc: (func: any) => any;
|
|
8
|
+
declare const buildWorkletFunc: (func: any) => any;
|
|
9
|
+
declare const functionArgsToWorkletize: Map<string, number[]>;
|
|
10
|
+
declare const objectHooks: Set<string>;
|
|
11
|
+
declare const globals: Set<string>;
|
|
12
|
+
declare const blacklistedFunctions: Set<string>;
|
|
13
|
+
declare const possibleOptFunction: Set<string>;
|
|
14
|
+
declare class ClosureGenerator {
|
|
15
|
+
constructor();
|
|
16
|
+
mergeAns(oldAns: any, newAns: any): any[];
|
|
17
|
+
findPrefixRec(path: any): any;
|
|
18
|
+
findPrefix(base: any, babelPath: any): any[];
|
|
19
|
+
addPath(base: any, babelPath: any): void;
|
|
20
|
+
generateNodeForBase(t: any, current: any, parent: any): any;
|
|
21
|
+
generate(t: any, variables: any, names: any): any;
|
|
22
|
+
}
|
|
23
|
+
declare function buildWorkletString(t: any, fun: any, closureVariables: any, name: any): any;
|
|
24
|
+
declare function generateWorkletFactory(t: any, fun: any): any;
|
|
25
|
+
declare function removeWorkletDirective(fun: any): undefined;
|
|
26
|
+
declare function makeWorkletName(t: any, fun: any): any;
|
|
27
|
+
declare function makeWorklet(t: any, fun: any, fileName: any): any;
|
|
28
|
+
declare function processWorkletFunction(t: any, fun: any, fileName: any): void;
|
|
29
|
+
declare function processWorkletObjectMethod(t: any, path: any, fileName: any): void;
|
|
30
|
+
declare function processIfWorkletNode(t: any, fun: any, fileName: any): void;
|
|
31
|
+
declare function processWorklets(t: any, path: any, fileName: any): void;
|
|
32
|
+
declare const FUNCTIONLESS_FLAG = 1;
|
|
33
|
+
declare const STATEMENTLESS_FLAG = 2;
|
|
34
|
+
declare function isPossibleOptimization(fun: any): number;
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
16
16
|
MINIPROGRAM_APP_JSON_NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
17
17
|
PLUGIN_JSON_NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
18
|
+
PLUGIN_PATH_SAME_WITH_MINIPROGRAM: import("./fomatable_string").FormatableString;
|
|
18
19
|
FILE_NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
19
20
|
JSON_PARSE_ERROR: import("./fomatable_string").FormatableString;
|
|
20
21
|
ENTRANCE_NOT_FOUND: import("./fomatable_string").FormatableString;
|
|
@@ -30,6 +31,8 @@ declare const _default: {
|
|
|
30
31
|
JSON_TABBAR_ICON_MAX_SIZE: import("./fomatable_string").FormatableString;
|
|
31
32
|
JSON_TABBAR_ICON_EXT: import("./fomatable_string").FormatableString;
|
|
32
33
|
JSON_CONTENT_SHOULD_NOT_BE: import("./fomatable_string").FormatableString;
|
|
34
|
+
JSON_RESOLVE_ALIAS_ILLEGAL: import("./fomatable_string").FormatableString;
|
|
35
|
+
JSON_RESOLVE_ALIAS_INCLUDE_STAR: import("./fomatable_string").FormatableString;
|
|
33
36
|
APP_JSON_SHOULD_SET_LAZYCODELOADING: import("./fomatable_string").FormatableString;
|
|
34
37
|
PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE: import("./fomatable_string").FormatableString;
|
|
35
38
|
PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM: import("./fomatable_string").FormatableString;
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
NOT_FOUND: FormatableString;
|
|
16
16
|
MINIPROGRAM_APP_JSON_NOT_FOUND: FormatableString;
|
|
17
17
|
PLUGIN_JSON_NOT_FOUND: FormatableString;
|
|
18
|
+
PLUGIN_PATH_SAME_WITH_MINIPROGRAM: FormatableString;
|
|
18
19
|
FILE_NOT_FOUND: FormatableString;
|
|
19
20
|
JSON_PARSE_ERROR: FormatableString;
|
|
20
21
|
ENTRANCE_NOT_FOUND: FormatableString;
|
|
@@ -30,6 +31,8 @@ declare const _default: {
|
|
|
30
31
|
JSON_TABBAR_ICON_MAX_SIZE: FormatableString;
|
|
31
32
|
JSON_TABBAR_ICON_EXT: FormatableString;
|
|
32
33
|
JSON_CONTENT_SHOULD_NOT_BE: FormatableString;
|
|
34
|
+
JSON_RESOLVE_ALIAS_ILLEGAL: FormatableString;
|
|
35
|
+
JSON_RESOLVE_ALIAS_INCLUDE_STAR: FormatableString;
|
|
33
36
|
APP_JSON_SHOULD_SET_LAZYCODELOADING: FormatableString;
|
|
34
37
|
PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE: FormatableString;
|
|
35
38
|
PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM: FormatableString;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* 根据入口JS文件路径,分析出所有依赖的js文件
|
|
4
3
|
* @public
|
|
@@ -64,6 +63,7 @@ export declare interface AnalyzerPlugin {
|
|
|
64
63
|
onModuleBuildFailed?(module: IModule, cost: number, error: Error): void;
|
|
65
64
|
afterModuleBuild?(module: IModule, cost: number, error: Error | null): void;
|
|
66
65
|
onModuleReuse?(module: IModule): void;
|
|
66
|
+
onModuleReuseFailed?(module: IModule, error: Error): void;
|
|
67
67
|
onModuleSerialize?(module: IModule, data: Record<string, any>): void;
|
|
68
68
|
onSerialize?(data: Record<string, any>): void;
|
|
69
69
|
}
|
|
@@ -141,6 +141,10 @@ export declare class Graph {
|
|
|
141
141
|
|
|
142
142
|
declare class GraphContext {
|
|
143
143
|
fileHelper: IFileHelper;
|
|
144
|
+
resolveAliasConf?: Array<{
|
|
145
|
+
key: string;
|
|
146
|
+
value: string;
|
|
147
|
+
}>;
|
|
144
148
|
es6Parser: {
|
|
145
149
|
isLayaGame: boolean;
|
|
146
150
|
};
|
|
@@ -149,6 +153,8 @@ declare class GraphContext {
|
|
|
149
153
|
};
|
|
150
154
|
constructor(options: GraphOptions);
|
|
151
155
|
private initMiniprogram;
|
|
156
|
+
setResolveAlias(resolveAlias: IAppJSON['resolveAlias']): void;
|
|
157
|
+
resolveJsFromAlias(request: string): string | undefined;
|
|
152
158
|
}
|
|
153
159
|
|
|
154
160
|
declare interface GraphOptions {
|
|
@@ -164,6 +170,31 @@ export declare interface IAnalyseResult {
|
|
|
164
170
|
modules: IModuleSerialize[];
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
declare interface IAppJSON {
|
|
174
|
+
pages?: string[];
|
|
175
|
+
workers?: string;
|
|
176
|
+
subPackages?: ISubpackageItem[];
|
|
177
|
+
subpackages?: ISubpackageItem[];
|
|
178
|
+
usingComponents?: IStringKeyMap;
|
|
179
|
+
plugins?: {
|
|
180
|
+
[alias: string]: IPluginConfig;
|
|
181
|
+
};
|
|
182
|
+
functionalPages?: boolean | {
|
|
183
|
+
independent?: boolean;
|
|
184
|
+
};
|
|
185
|
+
useExtendedLib?: {
|
|
186
|
+
[index: string]: boolean | string;
|
|
187
|
+
};
|
|
188
|
+
sitemapLocation?: string;
|
|
189
|
+
themeLocation?: string;
|
|
190
|
+
tabBar?: {
|
|
191
|
+
custom?: boolean;
|
|
192
|
+
};
|
|
193
|
+
resolveAlias?: {
|
|
194
|
+
[key: string]: string;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
167
198
|
/**
|
|
168
199
|
* @public
|
|
169
200
|
*/
|
|
@@ -206,6 +237,7 @@ export declare interface IFileHelper {
|
|
|
206
237
|
getJSON(filePath: string): Promise<unknown>;
|
|
207
238
|
readdir(dirPath: string): Promise<string[]>;
|
|
208
239
|
watchFileChange(callback: () => void): void;
|
|
240
|
+
getLocalFileString?(filePath: string): Promise<string>;
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
/**
|
|
@@ -222,6 +254,8 @@ export declare interface IModule {
|
|
|
222
254
|
type: ModuleErrorType;
|
|
223
255
|
error: any;
|
|
224
256
|
}>;
|
|
257
|
+
usePlugins?: Set<string>;
|
|
258
|
+
useTags?: Set<string>;
|
|
225
259
|
build(graphContext: GraphContext): Promise<IDep[]>;
|
|
226
260
|
reuse?(graphContext: GraphContext): Promise<void>;
|
|
227
261
|
isValid(): boolean;
|
|
@@ -258,6 +292,12 @@ export declare interface IPackageFile {
|
|
|
258
292
|
subPackage: string | null;
|
|
259
293
|
}
|
|
260
294
|
|
|
295
|
+
declare interface IPluginConfig {
|
|
296
|
+
version: string;
|
|
297
|
+
provider: string;
|
|
298
|
+
export?: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
261
301
|
/**
|
|
262
302
|
* @public
|
|
263
303
|
*/
|
|
@@ -268,6 +308,23 @@ export declare interface IStat {
|
|
|
268
308
|
size?: number;
|
|
269
309
|
}
|
|
270
310
|
|
|
311
|
+
declare interface IStringKeyMap<T = any> {
|
|
312
|
+
[propName: string]: T;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare interface ISubpackageItem {
|
|
316
|
+
name?: string;
|
|
317
|
+
root: string;
|
|
318
|
+
pages: string[];
|
|
319
|
+
plugins: {
|
|
320
|
+
[alias: string]: IPluginConfig;
|
|
321
|
+
};
|
|
322
|
+
independent: boolean;
|
|
323
|
+
useExtendedLib: {
|
|
324
|
+
[index: string]: boolean | string;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
271
328
|
/**
|
|
272
329
|
* @public
|
|
273
330
|
*/
|
package/dist/ci/code-analyse.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.analyseCode=void 0;const tslib_1=require("tslib"),projectconfig_1=require("../core/json/projectconfig"),code_analyse_1=require("../vendor/code-analyse"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.analyseCode=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"));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)}class LogPlugin{constructor(){this.name="LogPlugin"}onDepResolveFailed(e,o){var n,i;console.warn(`${null===(n=e.originModule)||void 0===n?void 0:n.type} module ${null===(i=e.originModule)||void 0===i?void 0:i.path} resolve dep failed`),console.warn(o)}onModuleBuildFailed(e,o,n){console.warn(`${e.type} module ${e.path} build failed`),console.warn(n)}}async function analyseCode(e,o){const n=(0,projectconfig_1.getProjectConfigJSON)(e),i=transCompileType(e);if("gamePlugin"===i)throw new Error("gamePlugin is not support yet!");let r="plugin"===i?n.pluginRoot:n.miniprogramRoot;r=r?path_1.default.posix.join(e.projectPath,r):e.projectPath;const t=new code_analyse_1.Analyzer({root:r,type:i,plugins:(null==o?void 0:o.silent)?[]:[new LogPlugin]});return await t.analyse(),t.serialize()}exports.analyseCode=analyseCode;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/ci/cos-upload.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uploadByCos=void 0;const tslib_1=require("tslib"),url_config_1=require("../utils/url_config"),tools_1=require("../utils/tools"),request_1=require("../utils/request"),sign_1=require("../utils/sign"),pack_1=require("./utils/pack"),zlib=require("zlib"),crypto=require("crypto"),config_1=require("../config"),upload_1=require("./upload"),log_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uploadByCos=void 0;const tslib_1=require("tslib"),url_config_1=require("../utils/url_config"),tools_1=require("../utils/tools"),request_1=require("../utils/request"),sign_1=require("../utils/sign"),pack_1=require("./utils/pack"),zlib=require("zlib"),crypto=require("crypto"),config_1=require("../config"),upload_1=require("./upload"),log_1=tslib_1.__importDefault(require("../utils/log")),jsonParse_1=require("../utils/jsonParse"),COS=require("cos-nodejs-sdk-v5");async function putBufferToCos(e,t){const r=new COS({Proxy:(0,request_1.getCiProxy)(),getAuthorization(e,r){r({TmpSecretId:t.secret_id,TmpSecretKey:t.secret_key,XCosSecurityToken:t.token,ExpiredTime:t.expired_time})}});try{return await new Promise((o,i)=>{r.putObject({Bucket:t.bucket,Region:"ap-shanghai",Key:t.object,Body:e,onProgress(e){}},(e,t)=>{if(e)return console.error(e),i(e.error);o(t)})})}catch(e){throw new Error("upload to cos failed: "+e.message)}}async function innerRequest(e,t){const r=await(0,request_1.request)({url:e,method:"post",body:t,headers:{"content-type":"application/json"}});let o;try{o=JSON.parse(r.body)}catch(t){const r=`request ${e} failed: resp body is not a valid json`;throw log_1.default.error(r),new Error(r)}if(0!==o.errCode)throw new Error(`request failed, errCode: ${o.errCode}, errMsg: ${o.errMsg}`);return o.data}async function uploadByCos(e,t,r,o){let i;try{const e=await(0,sign_1.getSignature)(r.privateKey,r.appid);i=await innerRequest(url_config_1.GET_UPLOAD_TOKEN,JSON.stringify({appid:r.appid,signature:e,robot:o}))}catch(e){return console.error("uploadToken error",e),{fallback:!0}}const s=e,a=crypto.randomBytes(12),n=crypto.createCipheriv("aes-256-gcm",Buffer.from(i.crypt_key,"base64"),a),u=Buffer.concat([n.update(s),n.final()]),c=n.getAuthTag(),l=Buffer.alloc(1);l.writeUInt8(c.length+a.length,0);const p=Buffer.concat([l,c,a,u]),d=Date.now();await putBufferToCos(p,i);const _=Date.now()-d,f=(0,tools_1.generateMD5)(s),g=await(0,sign_1.getSignature)(r.privateKey,r.appid),y=`${t}&task_id=${i.task_id}&new_hash=${f}&upload_cos_cost_time=${_}`;log_1.default.info("request url:",y);let w=await(0,request_1.request)({url:y,method:"post",body:zlib.gzipSync((0,pack_1.pack)({[upload_1.SIGNATURE_FILE_NAME]:JSON.stringify({signature:g,version:config_1.CI_VERSION})}).buffer)});if(0!==(0,jsonParse_1.jsonRespParse)(w.body.toString(),t).errCode)throw new Error(w.body.toString());for(;;){const e=await(0,sign_1.getSignature)(r.privateKey,r.appid),t=await innerRequest(`${url_config_1.GET_ASYNC_RESULT}?task_id=${i.task_id}`,JSON.stringify({appid:r.appid,signature:e,robot:o}));if(1!==t.status){if(0===t.status)return{fallback:!1,body:t,uploadCOSCostTime:_};if(3===t.status)throw new Error(`upload failed with status ${t.status}, task not found`);throw new Error("upload failed with status "+t.status)}await new Promise(e=>{setTimeout(e,1e3)})}}exports.uploadByCos=uploadByCos;
|
|
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.getCompiledResult=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),fs_extra_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCompiledResult=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),compile_1=require("../core/compile"),config_1=require("../config"),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),cache_1=require("../utils/cache"),jszip_1=tslib_1.__importDefault(require("jszip")),path_1=tslib_1.__importDefault(require("path"));async function getCompiledResult(e,t){const{project:r,setting:o={},version:i="",onProgressUpdate:s=function(e){console.log(""+e)},threads:a=0,includedMap:l=!1}=e;if(process.env.COMPILE_THREADS=a.toString(),!i)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","version"),config_1.PARAM_ERROR);if(!r)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","project"),config_1.PARAM_ERROR);cache_1.cacheManager.clean();const _=await(0,compile_1.compile)(r,{setting:o,onProgressUpdate:s}),c={};if(Object.keys(_).sort().forEach(e=>{e.endsWith("js.map")&&!l||(c[e]=_[e])}),t){const e=new jszip_1.default;Object.keys(c).forEach(t=>{e.folder(path_1.default.dirname(t)).file(path_1.default.basename(t),c[t])});const r=await e.generateAsync({type:"nodebuffer"});fs_extra_1.default.ensureDirSync(path_1.default.dirname(t)),fs_extra_1.default.writeFileSync(t,r)}return c}exports.SIGNATURE_FILE_NAME="ci.signature",exports.getCompiledResult=getCompiledResult;
|
|
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.getDevSourceMap=void 0;const tslib_1=require("tslib"),fs_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDevSourceMap=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),log_1=tslib_1.__importDefault(require("../utils/log")),request_1=require("../utils/request"),url_config_1=require("../utils/url_config"),sign_1=require("../utils/sign"),JsZip=require("jszip"),ERR_MSG_PREFIX="download source map failed:";async function getDevSourceMap(e){return new Promise(async(r,t)=>{const{project:o,robot:a}=e;let{sourceMapSavePath:i}=e;if(!o){const e="params project is requried";return log_1.default.error(e),void t(e)}if("number"!=typeof a||Math.round(a)>30||Math.round(a)<=0){const e="params robot is invalid";return log_1.default.error(e),void t(e)}if(!i){const e="params sourceMapSavePath is invalid";return log_1.default.error(e),void t(e)}path_1.default.isAbsolute(i)||(i=path_1.default.join(process.cwd(),i));const s=await(0,sign_1.getSignature)(o.privateKey,o.appid),{body:u}=await(0,request_1.request)({url:url_config_1.GET_DEV_SOURCE_MAP,method:"post",gzip:!0,body:JSON.stringify({appid:o.appid,signature:s,robot:a}),headers:{"content-type":"application/json"}});let l;try{l=JSON.parse(u)}catch(e){const r=ERR_MSG_PREFIX+" resp body is not a valid json";return log_1.default.error(r),void t(r)}const n=l.data;if(!Array.isArray(n.sourcemap_list)){const e=`${ERR_MSG_PREFIX} respData.sourcemap_list, respData: ${JSON.stringify(n)}`;return log_1.default.error(e),void t(e)}const p=n.sourcemap_list,_=new JsZip;try{p.forEach(e=>{_.folder(path_1.default.dirname(e.fullpath)).file(path_1.default.basename(e.fullpath),e.sourcemap)})}catch(e){const r=ERR_MSG_PREFIX+" source map add folder or add file error";return log_1.default.error(r),void t(r)}_.generateAsync({type:"nodebuffer"}).then(e=>{try{fs_1.default.writeFileSync(i,e),r(void 0)}catch(e){const r=`${ERR_MSG_PREFIX} save source map to ${i} failed. Error detail: ${JSON.stringify(e)}`;return log_1.default.error(r),void t(r)}r(e)}).catch(()=>{const e=ERR_MSG_PREFIX+" source map generate zip error";log_1.default.error(e),t(e)})})}exports.getDevSourceMap=getDevSourceMap;
|
|
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.getLatestVersion=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),sign_1=require("../utils/sign"),config_1=require("../config"),error_1=require("../utils/error"),locales_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLatestVersion=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),sign_1=require("../utils/sign"),config_1=require("../config"),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),querystring_1=tslib_1.__importDefault(require("querystring")),url_config_1=require("../utils/url_config"),jsonParse_1=require("../utils/jsonParse");async function getLatestVersion(e){const{project:r}=e;if(!r)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("getLatestVersion","project"),config_1.PARAM_ERROR);if("miniProgramPlugin"!==r.type&&"miniGamePlugin"!==r.type)throw new Error("getLatestVersion only support plugin type project");const t=await(0,sign_1.getSignature)(r.privateKey,r.appid),i={appid:r.appid,signature:t};try{const e=`${url_config_1.GET_LATEST_VERSION}?${querystring_1.default.stringify(i)}`,r=(await(0,request_1.request)({url:e,method:"get"})).body.toString(),t=(0,jsonParse_1.jsonRespParse)(r,e);if(0!==t.errCode)throw new Error(r);return t.data}catch(e){throw new error_1.CodeError(e.toString(),config_1.GET_LATEST_VERSION_CGI_ERR)}}exports.getLatestVersion=getLatestVersion;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/ci/jsserver.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uploadJsServer=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uploadJsServer=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),request_1=require("../utils/request"),packfile_1=require("./utils/packfile"),zlib_1=tslib_1.__importDefault(require("zlib")),sign_1=require("../utils/sign"),config_1=require("../config"),log_1=tslib_1.__importDefault(require("../utils/log")),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),querystring_1=tslib_1.__importDefault(require("querystring")),url_config_1=require("../utils/url_config"),jsonParse_1=require("../utils/jsonParse"),projectconfig_1=require("../core/json/projectconfig");async function uploadJsServer(e){var r;const{project:o,env:t}=e;if(!t||"test"!==t&&"release"!==t)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("uploadJsServer","env"),config_1.PARAM_ERROR);if(!o)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("uploadJsServer","project"),config_1.PARAM_ERROR);const i=(0,projectconfig_1.getProjectConfigJSON)(o);if("string"!=typeof i.jsserverRoot||!(null===(r=o.stat("",i.jsserverRoot))||void 0===r?void 0:r.isDirectory))throw new error_1.CodeError("please set a correct jsserverRoot value in project.config.json",config_1.PARAM_ERROR);const s=await(0,packfile_1.packFiledir)(path_1.default.posix.join(o.projectPath,i.jsserverRoot)),_=await(0,sign_1.getSignature)(o.privateKey,o.appid),l={type:"release"===t?0:1,appid:o.appid,signature:_};try{const e=`${url_config_1.UPLOAD_JS_SERVER}?${querystring_1.default.stringify(l)}`;log_1.default.info("request url:",e);const r=zlib_1.default.gzipSync(s.data),o=(await(0,request_1.request)({url:e,method:"post",body:r})).body.toString();if(0!==(0,jsonParse_1.jsonRespParse)(o,e).errCode)throw new Error(o);return!0}catch(e){throw new error_1.CodeError(e.toString(),config_1.UPLOAD_JS_SERVER_CGI_ERR)}}exports.SIGNATURE_FILE_NAME="ci.signature",exports.uploadJsServer=uploadJsServer;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/ci/preview.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.preview=void 0;const tslib_1=require("tslib"),upload_1=require("./upload"),terminalQrcode_1=require("./utils/terminalQrcode"),fs_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.preview=void 0;const tslib_1=require("tslib"),upload_1=require("./upload"),terminalQrcode_1=require("./utils/terminalQrcode"),fs_1=tslib_1.__importDefault(require("fs")),config_1=require("../config"),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),log_1=tslib_1.__importDefault(require("../utils/log"));async function preview(e){const r=Object.assign({},e);if(r.test=!0,r.version="0.0.1",r.qrcodeFormat||(r.qrcodeFormat="terminal"),!["base64","image","terminal"].includes(r.qrcodeFormat))throw new error_1.CodeError(locales_1.default.config.INVALID.format("qrcodeFormat"),config_1.PARAM_ERROR);if(["base64","image"].includes(r.qrcodeFormat)&&("string"!=typeof r.qrcodeOutputDest||"."===r.qrcodeOutputDest.trim()))throw new error_1.CodeError(locales_1.default.config.INVALID.format("qrcodeOutputDest"),config_1.PARAM_ERROR);const o=await(0,upload_1.innerUpload)(r);if(!o.respBody.qrcode_img)throw new Error("No `qrcode_img` in response.");if("terminal"===r.qrcodeFormat)try{const e=await(0,terminalQrcode_1.generateTerminalQrcode)(o.respBody.qrcode_img);log_1.default.log(e),log_1.default.log("terminal qrcode shown above")}catch(e){log_1.default.error("Termianl qrcode generate failed, but you can still visit the dev version on your cell phone.")}else if(r.qrcodeOutputDest)if("image"===r.qrcodeFormat)try{fs_1.default.writeFileSync(r.qrcodeOutputDest,Buffer.from(o.respBody.qrcode_img,"base64")),log_1.default.info(`Qrcode image saved, file path: '${r.qrcodeOutputDest}'`)}catch(e){throw new Error("write qrcode image error: "+JSON.stringify(e))}else if("base64"===r.qrcodeFormat)try{fs_1.default.writeFileSync(r.qrcodeOutputDest,"data:image/jpeg;base64,"+o.respBody.qrcode_img,"utf8"),log_1.default.info(`Qrcode base64 file saved, file path: '${r.qrcodeOutputDest}'`)}catch(e){throw new Error("write qrcode base64 error: "+JSON.stringify(e))}return{subPackageInfo:o.subPackageInfo,pluginInfo:o.pluginInfo}}exports.preview=preview;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/ci/project.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Project=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Project=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),glob_1=tslib_1.__importDefault(require("glob")),fs_1=tslib_1.__importDefault(require("fs")),projectattr_1=require("./projectattr"),tools_1=require("../utils/tools"),config_1=require("../config"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),error_1=require("../utils/error"),request_1=require("../utils/request"),projectconfig_1=require("../core/json/projectconfig"),defaultIgnores=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];class Project{constructor(t){this.miniprogramRoot="",this.pluginRoot="",this._appid="",this._projectPath="",this._dirSet=new Set,this._fileSet=new Set,this._fileBufferCache={},this._privateKey="",this._ignores=[];const{appid:e,type:i,projectPath:r,ignores:s,privateKey:o="",privateKeyPath:a=""}=t;if(!e)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("appid"),config_1.PARAM_ERROR);if(!r)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if(o)this._privateKey=o;else{if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("privateKeyPath"),config_1.PARAM_ERROR);try{this._privateKey=fs_1.default.readFileSync(a).toString("utf8")}catch(t){throw new error_1.CodeError(t.toString(),config_1.PARAM_ERROR)}}this._appid=e,this._type=i||"miniProgram",this._projectPath=r,this.init(s)}init(t=[]){(0,request_1.initGlobalProxy)(),this._ignores=t,this.updateFiles()}cacheDirName(t){this._dirSet.has(t)||(this._dirSet.add(t),this.cacheDirName(path_1.default.posix.dirname(t)))}getTargetPath(t,e){return(0,tools_1.normalizePath)(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}updateFiles(){this._fileBufferCache={};const t=glob_1.default.sync("**",{nodir:!1,ignore:[...defaultIgnores,...this._ignores],nosort:!0,strict:!1,silent:!0,cwd:this.projectPath,absolute:!1,mark:!0,dot:!0});for(const e of t){const t=e.replace(/\\/g,path_1.default.posix.sep),i=fs_1.default.statSync(path_1.default.posix.join(this.projectPath,e));i.isDirectory()&&this.cacheDirName(t.replace(/\/$/,"")),i.isFile()&&(this._fileSet.add(t),this.cacheDirName(path_1.default.posix.dirname(t)))}}async attr(){return this._attr||(this._attr=await(0,projectattr_1.getProjectAttr)(this._privateKey,this._appid)),this._attr}get projectPath(){return this._projectPath}get appid(){return this._appid}get type(){return this._type}get privateKey(){return this._privateKey||""}getFilesAndDirs(){return{files:Array.from(this._fileSet),dirs:Array.from(this._dirSet)}}async getExtAppid(){if(this._extAppid)return this._extAppid;if(null!==this._extAppid)try{const t=await(0,projectconfig_1.getProjectConfigJSON)(this),{miniprogramRoot:e=""}=t,i=await this.getFile(e,"ext.json"),r=JSON.parse(i.toString("utf-8"));return r.extEnable&&r.extAppid?this._extAppid=r.extAppid:this._extAppid=null,this._extAppid}catch(t){this._extAppid=null}}stat(t,e){const i=this.getTargetPath(t,e);if(this._fileSet.has(i)){return{isFile:!0,isDirectory:!1,size:fs_1.default.statSync(path_1.default.posix.join(this.projectPath,i)).size}}if(this._dirSet.has(i))return{isFile:!1,isDirectory:!0}}getFile(t,e){const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return this._fileBufferCache[i]?this._fileBufferCache[i]:fs_1.default.readFileSync(r,null)}getFileList(t,e=""){return Array.from(this._fileSet).filter(i=>(!e||path_1.default.posix.extname(i)===e)&&(!t||0===i.indexOf(t)))}async onFileChange(t,e){if(e=(0,tools_1.normalizePath)(e).replace(/\/$/,"").replace(/^\//,""),"add"!==t&&"addDir"!==t||(this.cacheDirName(path_1.default.posix.dirname(e)),this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(e),"unlink"===t&&this._fileSet.has(e)&&this._fileSet.delete(e),"unlinkDir"===t&&this._dirSet.has(e)){this._dirSet.delete(e);const t=e+"/",i=Array.from(this._dirSet);for(const e of i)0===e.indexOf(t)&&this._dirSet.delete(e);const r=Array.from(this._fileSet);for(const e of r)0===e.indexOf(t)&&this._fileSet.delete(e)}"change"===t&&this._fileSet.has(e)&&delete this._fileBufferCache[e]}}exports.Project=Project;
|
|
3
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=
|
|
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;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/ci/upload.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.innerUpload=exports.upload=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),compile_1=require("../core/compile"),pack_1=require("./utils/pack"),zlib_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.innerUpload=exports.upload=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),compile_1=require("../core/compile"),pack_1=require("./utils/pack"),zlib_1=tslib_1.__importDefault(require("zlib")),sign_1=require("../utils/sign"),tools_1=require("../utils/tools"),config_1=require("../config"),taskstatus_1=require("../utils/taskstatus"),log_1=tslib_1.__importDefault(require("../utils/log")),error_1=require("../utils/error"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),querystring_1=tslib_1.__importDefault(require("querystring")),url_config_1=require("../utils/url_config"),jsonParse_1=require("../utils/jsonParse"),cache_1=require("../utils/cache"),cos_upload_1=require("./cos-upload");exports.SIGNATURE_FILE_NAME="ci.signature";const MIN_COS_UPLOAD_SIZE=5242880;async function upload(e){var o;const t=await innerUpload(e);return(null===(o=t.respBody)||void 0===o?void 0:o.dev_plugin_id)&&(log_1.default.log("Development Version Plugin ID: "+t.respBody.dev_plugin_id),t.devPluginId=t.respBody.dev_plugin_id),{subPackageInfo:t.subPackageInfo,pluginInfo:t.pluginInfo,devPluginId:t.devPluginId}}async function innerUpload(e){const{project:o,setting:t={},desc:r=`robot ${e.robot||"1"} use miniprogram-ci to upload at ${(0,tools_1.formatTime)(new Date)}`,version:i="",robot:a="1",onProgressUpdate:l=function(e){console.log(""+e)},test:s,pagePath:n,searchQuery:u,threads:p=0}=e;let{useCOS:_}=e;if(process.env.COMPILE_THREADS=p.toString(),!i)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","version"),config_1.PARAM_ERROR);if(!o)throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("upload","project"),config_1.PARAM_ERROR);cache_1.cacheManager.clean();let d=await(0,compile_1.compile)(o,{setting:t,onProgressUpdate:l}),c=config_1.CI_VERSION;const f={codeprotect:t.codeProtect?1:0,type:o.type,appid:o.appid,version:i,desc:r,robot:a},g={scene:e.scene||1011};let b;n&&(g.path=n,f.path=n),u&&(g.query=querystring_1.default.parse(u)),f.debugLaunchInfo=JSON.stringify(g),n&&u&&(f.path+="?"+u);let y={};try{b=await o.getFile(o.miniprogramRoot,"ext.json"),y=JSON.parse(b.toString("utf-8"))}catch(e){}if(y&&(y.extEnable&&(f.extAppId=y.extAppid),y.directCommit)){let e="";e=y.extEnable?"The code will be uploaded into the waiting list of extAppid.":"The code will be uploaded into the draft box of the third-party platform.",log_1.default.warn(e)}try{const e=new taskstatus_1.TaskStatus(locales_1.default.config.UPLOAD.toString());l(e);const t=`${s?url_config_1.TEST_SOURCE_URL:url_config_1.UPLOAD_URL}?${querystring_1.default.stringify(f)}`;let r,i=!1,n=0;const u=(0,pack_1.pack)(d),p=zlib_1.default.gzipSync(u.buffer);if(log_1.default.info("useCOS parameter: ",_),log_1.default.info("upload zip buffer size: ",p.length),void 0===_&&(_=p.length>5242880),_){log_1.default.info("upload by COS: ",_);const e=await(0,cos_upload_1.uploadByCos)(p,t,o,a);e.fallback?(i=e.fallback,log_1.default.info("upload by COS failed, fallback to http way")):(r={body:e.body},n=e.uploadCOSCostTime)}if(!_||i){const e=await(0,sign_1.getSignature)(o.privateKey,o.appid);d[exports.SIGNATURE_FILE_NAME]=JSON.stringify({signature:e,version:c});const i=(0,pack_1.pack)(d),a=zlib_1.default.gzipSync(i.buffer);log_1.default.info("request url:",t);let l=(await(0,request_1.request)({url:t,method:"post",body:a})).body.toString();if(r=(0,jsonParse_1.jsonRespParse)(l,t),0!==r.errCode)throw new Error(l)}e.done(),l(e);const g={respBody:r.body};if(Array.isArray(r.body.subpackage_info)){const e=r.body.subpackage_info;g.subPackageInfo=e}if(Array.isArray(r.body.ext_plugin_info)){const e=r.body.ext_plugin_info;g.pluginInfo=e.map(e=>({pluginProviderAppid:e.provider,version:e.version,size:e.size}))}return g}catch(e){throw new error_1.CodeError(e.toString(),config_1.UPLOAD_CGI_ERR)}}exports.upload=upload,exports.innerUpload=innerUpload;
|
|
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.packFiledir=exports.packFileMap=void 0;const tslib_1=require("tslib"),fs_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packFiledir=exports.packFileMap=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),crypto_1=tslib_1.__importDefault(require("crypto")),glob_1=tslib_1.__importDefault(require("glob")),packFileMap=(e,t={})=>{const r=[Buffer.alloc(1),Buffer.alloc(4),Buffer.alloc(4),Buffer.alloc(4),Buffer.alloc(1)];r[0][0]=190,r[1].writeInt32BE(0,0),r[4][0]=237;let o=0;const l=[],c=[],f={};let i=0;for(const r in e){const n=Buffer.isBuffer(e[r])?e[r]:Buffer.from(e[r]);if(t.needMd5){const e=crypto_1.default.createHash("md5");e.update(n);const o=e.digest("hex");if(f[r]=o,t.ignoreFileMd5&&t.ignoreFileMd5[r]===o)continue}const a=Buffer.from("/"+r.replace(/\\/g,"/"));o++,l.push(a),c.push(n),/\.js\.map$/.test(r)||(i+=n.length,i+=a.length,i+=12)}let n=18+12*o+Buffer.concat(l).length;const a=l.map((e,t)=>{const r=Buffer.alloc(4);r.writeInt32BE(e.length,0);const o=Buffer.alloc(4),l=c[t].length,f=n;o.writeInt32BE(f,0),n+=l;const i=Buffer.alloc(4);return i.writeInt32BE(l,0),Buffer.concat([r,e,o,i])}),s=Buffer.alloc(4);s.writeInt32BE(o,0),a.unshift(s);const u=Buffer.concat(a),p=Buffer.concat(c);r[2].writeInt32BE(u.length,0),r[3].writeInt32BE(p.length,0);const B=Buffer.concat(r);return i+=18,{data:Buffer.concat([B,u,p]),totalSize:i,fileMd5Info:f}};exports.packFileMap=packFileMap;const packFiledir=(e,t={})=>new Promise((r,o)=>{const l=Object.assign({nodir:!0},t);(0,glob_1.default)(e+"/**",l,(l,c)=>{if(l)return o(l);const f={};c.forEach(t=>{const r=fs_1.default.readFileSync(t),o=path_1.default.relative(e,t);f[o]=r});const i=(0,exports.packFileMap)(f,t);r(i)})});exports.packFiledir=packFiledir;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|