miniprogram-ci 2.0.4 → 2.0.6
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 +5 -0
- package/README.md +12 -7
- package/dist/@types/config/config.d.ts +1 -1
- package/dist/@types/modules/index.d.ts +1 -2
- package/dist/@types/modules/nativecompiler/index.d.ts +1 -0
- package/dist/@types/modules/nativecompiler/ios/index.d.ts +1 -0
- package/dist/@types/modules/nativecompiler/nativeCompiler.d.ts +4 -0
- package/dist/@types/types/miniapp/index.d.ts +15 -0
- package/dist/@types/utils/codesign.d.ts +2 -1
- package/dist/@types/utils/tools.d.ts +1 -1
- package/dist/ci/upload.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/config.js +1 -1
- package/dist/modules/corecompiler/original/json/page/getPageJSON.js +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/nativecompiler/index.js +1 -1
- package/dist/modules/nativecompiler/ios/device.js +1 -1
- package/dist/modules/nativecompiler/ios/index.js +1 -1
- package/dist/modules/nativecompiler/nativeCompiler.js +1 -1
- package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
- package/dist/static/scripts/resignIpa +19 -11
- package/dist/utils/codesign.js +1 -1
- package/dist/utils/generateIpa.js +1 -1
- package/dist/utils/log.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -8,6 +8,11 @@ miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,
|
|
|
8
8
|
|
|
9
9
|
## 最近变更
|
|
10
10
|
|
|
11
|
+
#### 2.0.6
|
|
12
|
+
- `fix` 修复 未设置 onProgressUpdate 输出日志为[object Object]的问题
|
|
13
|
+
#### 2.0.5
|
|
14
|
+
- `fix` 修复 命令行执行完不退出的问题
|
|
15
|
+
- `fix` 修复 输出日志为[object Object]的问题
|
|
11
16
|
#### 2.0.4
|
|
12
17
|
- `fix` 修复 代码包体积变大的问题
|
|
13
18
|
#### 2.0.3
|
|
@@ -133,7 +138,7 @@ const ci = require('miniprogram-ci')
|
|
|
133
138
|
version: '1.1.1',
|
|
134
139
|
desc: 'hello',
|
|
135
140
|
setting: {
|
|
136
|
-
|
|
141
|
+
useProjectConfig: true,
|
|
137
142
|
},
|
|
138
143
|
onProgressUpdate: console.log,
|
|
139
144
|
})
|
|
@@ -179,7 +184,7 @@ const ci = require('miniprogram-ci')
|
|
|
179
184
|
project,
|
|
180
185
|
desc: 'hello',
|
|
181
186
|
setting: {
|
|
182
|
-
|
|
187
|
+
useProjectConfig: true,
|
|
183
188
|
},
|
|
184
189
|
qrcodeFormat: 'image',
|
|
185
190
|
qrcodeOutputDest: '/path/to/qrcode/file/destination.jpg',
|
|
@@ -271,7 +276,7 @@ const path = require('path')
|
|
|
271
276
|
project,
|
|
272
277
|
desc: 'hello',
|
|
273
278
|
setting: {
|
|
274
|
-
|
|
279
|
+
useProjectConfig: true,
|
|
275
280
|
},
|
|
276
281
|
qrcodeFormat: 'image',
|
|
277
282
|
qrcodeOutputDest: '/path/to/qrcode/file/destination.jpg',
|
|
@@ -773,7 +778,7 @@ miniprogram-ci \
|
|
|
773
778
|
--appid YOUR_APPID \
|
|
774
779
|
--uv PACKAGE_VERSION \
|
|
775
780
|
-r 1 \
|
|
776
|
-
--
|
|
781
|
+
--use-project-config true \
|
|
777
782
|
--proxy YOUR_PROXY \
|
|
778
783
|
--qrcode-format image \
|
|
779
784
|
--qrcode-output-dest '/tmp/x.jpg' \
|
|
@@ -787,7 +792,7 @@ miniprogram-ci \
|
|
|
787
792
|
--appid YOUR_APPID \
|
|
788
793
|
--uv PACKAGE_VERSION \
|
|
789
794
|
-r 1 \
|
|
790
|
-
--
|
|
795
|
+
--use-project-config true \
|
|
791
796
|
|
|
792
797
|
#get-compiled-result
|
|
793
798
|
miniprogram-ci \
|
|
@@ -797,7 +802,7 @@ miniprogram-ci \
|
|
|
797
802
|
--appid YOUR_APPID \
|
|
798
803
|
--uv PACKAGE_VERSION \
|
|
799
804
|
-r 1 \
|
|
800
|
-
--
|
|
805
|
+
--use-project-config true \
|
|
801
806
|
--save-path ./compiledResult.zip
|
|
802
807
|
|
|
803
808
|
#check-code-quality
|
|
@@ -876,7 +881,7 @@ miniprogram-ci \
|
|
|
876
881
|
--appid YOUR_APPID \
|
|
877
882
|
--uv PACKAGE_VERSION \
|
|
878
883
|
-r 1 \
|
|
879
|
-
--
|
|
884
|
+
--use-project-config true \
|
|
880
885
|
--proxy YOUR_PROXY_URL # 也可以使用这个参数声明proxy
|
|
881
886
|
|
|
882
887
|
#get dev source map
|
|
@@ -4,7 +4,6 @@ import { IMessageHub, IConsoleDisplay } from '../utils/messageHub';
|
|
|
4
4
|
import { PreCompiler } from './precompiler/index';
|
|
5
5
|
import { SummerCompiler } from './corecompiler/summerCompiler';
|
|
6
6
|
import { NativeCompiler } from './nativecompiler';
|
|
7
|
-
import { OriginalCompiler } from './corecompiler/originalCompiler';
|
|
8
7
|
interface IBuilderOptions {
|
|
9
8
|
summerCompilerClass?: typeof SummerCompiler;
|
|
10
9
|
cachePath?: string;
|
|
@@ -27,7 +26,7 @@ export declare class Builder {
|
|
|
27
26
|
private _checkReadyTask?;
|
|
28
27
|
private _originalCompiler;
|
|
29
28
|
constructor(project: MiniProgramCI.IProject, opts: IBuilderOptions);
|
|
30
|
-
getCompiler(): Promise<
|
|
29
|
+
getCompiler(): Promise<SummerCompiler>;
|
|
31
30
|
getPreCompileProject(): Promise<PreCompileProject>;
|
|
32
31
|
getPreCompiler(): Promise<PreCompiler>;
|
|
33
32
|
getSummerCompiler(): Promise<SummerCompiler>;
|
|
@@ -24,6 +24,7 @@ export declare class NativeCompiler {
|
|
|
24
24
|
runIOS(opts: IMiniApp.IIOSRunLocalSimpleArgs | IMiniApp.IIOSRunCloudSimpleArgs): Promise<void>;
|
|
25
25
|
buildAndroidAPK(opts: IMiniApp.IAndroidBuildLocalSimpleArgs | IMiniApp.IAndroidBuildCloudSimpleArgs): Promise<string>;
|
|
26
26
|
buildIOSIPA(opts: IMiniApp.IIOSBuildLocalSimpleArgs | IMiniApp.IIOSBuildCloudSimpleArgs): Promise<string>;
|
|
27
|
+
codesignIpa(opts: IMiniApp.CodesignIpaArgs): Promise<string>;
|
|
27
28
|
buildAndroidPlugin(opts: IMiniApp.IAndroidBuildPluginArgs): Promise<void>;
|
|
28
29
|
buildIOSPlugin(opts: IMiniApp.IBuildPluginIOSFrameworkArgs): Promise<void>;
|
|
29
30
|
packIOSCloudBuildMaterial(opts: IMiniApp.IIOSBuildCloudGenMaterialArgs): Promise<string>;
|
|
@@ -30,6 +30,7 @@ export declare class IOSUtils {
|
|
|
30
30
|
buildLocal(args: IMiniApp.IIOSBuildLocalArgs, recorder: Recorder): Promise<string>;
|
|
31
31
|
buildCloud(args: IMiniApp.IIOSBuildCloudArgs, recorder: Recorder): Promise<void>;
|
|
32
32
|
genProjectMaterialMap(projectPath: string, matrialDistPath: string, buildArgs: IMiniApp.IIOSBuildCloudGenMaterialArgs, recorder: Recorder): Promise<IProjectMaterialPathMap>;
|
|
33
|
+
codesignIOSApp(args: IMiniApp.CodesignIpaArgs, recorder: Recorder): Promise<void>;
|
|
33
34
|
packIOSCloudBuildMaterial(args: IMiniApp.IIOSBuildCloudGenMaterialArgs, recorder: Recorder): Promise<void>;
|
|
34
35
|
private launchSimulator;
|
|
35
36
|
private runOnSimulatorCloud;
|
|
@@ -36,5 +36,9 @@ export declare class NativeCompiler {
|
|
|
36
36
|
targetPlatform: MiniProgramCore.ITargetPlatform;
|
|
37
37
|
opts: IMiniApp.IIOSBuildCloudGenMaterialArgs;
|
|
38
38
|
}, recorder: Recorder): Promise<any>;
|
|
39
|
+
codesignIOSApp(data: {
|
|
40
|
+
targetPlatform: MiniProgramCore.ITargetPlatform;
|
|
41
|
+
opts: IMiniApp.CodesignIpaArgs;
|
|
42
|
+
}, recorder: Recorder): Promise<any>;
|
|
39
43
|
}
|
|
40
44
|
export {};
|
|
@@ -111,6 +111,21 @@ export declare namespace IMiniApp {
|
|
|
111
111
|
scheme: string;
|
|
112
112
|
exportOptionPlistPath?: string;
|
|
113
113
|
};
|
|
114
|
+
type CodesignIpaArgs = {
|
|
115
|
+
projectPath: string;
|
|
116
|
+
demoIpaPath: string;
|
|
117
|
+
miniappCacheDir: string;
|
|
118
|
+
opts: {
|
|
119
|
+
output: string;
|
|
120
|
+
outputAppWithName?: string;
|
|
121
|
+
bundleId?: string;
|
|
122
|
+
certificate?: string;
|
|
123
|
+
profile?: string;
|
|
124
|
+
tpnsProfile?: string;
|
|
125
|
+
};
|
|
126
|
+
isUsingTpush: boolean;
|
|
127
|
+
_inLandun?: boolean;
|
|
128
|
+
};
|
|
114
129
|
type ITranslations = {
|
|
115
130
|
common?: Record<string, string>;
|
|
116
131
|
ios?: Record<string, string>;
|
|
@@ -4,12 +4,13 @@ export interface IEntitlements {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function codesignAndExport(projectPath: string, demoIpaPath: string, miniappCacheDir: string, opts: {
|
|
6
6
|
output: string;
|
|
7
|
+
outputAppWithName?: string;
|
|
7
8
|
entitlements?: IEntitlements;
|
|
8
9
|
bundleId?: string;
|
|
9
10
|
certificate?: string;
|
|
10
11
|
profile?: string;
|
|
11
12
|
tpnsProfile?: string;
|
|
12
|
-
}, recorder: Recorder, isUsingTpush: boolean, _inLandun?: boolean): Promise<{
|
|
13
|
+
}, recorder: Recorder, isUsingTpush: boolean, _inLandun?: boolean, _selectForCerficate?: boolean): Promise<{
|
|
13
14
|
success: boolean;
|
|
14
15
|
errMsg?: undefined;
|
|
15
16
|
} | {
|
|
@@ -37,4 +37,4 @@ export declare const compareVersion: (v1: any, v2: any) => 0 | 1 | -1;
|
|
|
37
37
|
export declare const pathRelative: (left: string, right: string) => string;
|
|
38
38
|
export declare function isLeftSubPathOfRight(child: string, parent: string): boolean;
|
|
39
39
|
export declare function isGameApp(project: MiniProgramCI.IProject): boolean;
|
|
40
|
-
export declare const checkIsUseCompilerPlugins: (
|
|
40
|
+
export declare const checkIsUseCompilerPlugins: () => boolean;
|
package/dist/ci/upload.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.innerUpload=exports.upload=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),log=tslib_1.__importStar(require("../utils/log")),request_1=require("../utils/request"),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/config"),taskstatus_1=require("../utils/taskstatus"),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("../config/url.config"),jsonParse_1=require("../utils/jsonParse"),cache_1=require("../utils/cache"),cos_upload_1=require("./cos-upload"),filterUnusedFile_1=require("./utils/filterUnusedFile"),getcompiler_1=require("./getcompiler"),tools_2=require("./utils/tools");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.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={useProjectConfig:!1},desc:r=`robot ${e.robot||"1"} use miniprogram-ci to upload at ${(0,tools_1.formatTime)(new Date)}`,version:i="",robot:s="1",onProgressUpdate:n=function(e){console.log(""+e)},test:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.innerUpload=exports.upload=exports.SIGNATURE_FILE_NAME=void 0;const tslib_1=require("tslib"),log=tslib_1.__importStar(require("../utils/log")),request_1=require("../utils/request"),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/config"),taskstatus_1=require("../utils/taskstatus"),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("../config/url.config"),jsonParse_1=require("../utils/jsonParse"),cache_1=require("../utils/cache"),cos_upload_1=require("./cos-upload"),filterUnusedFile_1=require("./utils/filterUnusedFile"),getcompiler_1=require("./getcompiler"),tools_2=require("./utils/tools");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.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={useProjectConfig:!1},desc:r=`robot ${e.robot||"1"} use miniprogram-ci to upload at ${(0,tools_1.formatTime)(new Date)}`,version:i="",robot:s="1",onProgressUpdate:n=function(e){if("object"==typeof e)try{const o=JSON.stringify(e);return void console.log(o)}catch(e){}console.log(""+e)},test:l,pagePath:a,searchQuery:u,threads:p=0,bigPackageSizeSupport:c,allowIgnoreUnusedFiles:d=!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();const g=await(0,getcompiler_1.getCompiler)(o,t),f=(0,tools_2.formatCISetting)(o,t);let b=await g.compile({setting:f,onProgressUpdate:n,resultType:"prod"});!1!==d&&(b=await(0,filterUnusedFile_1.filterUnusedFile)(!!l,o,b));const y=config_1.CI_VERSION,S={codeprotect:t.codeProtect?1:0,type:o.type,appid:o.appid,version:i,desc:r,robot:s},q={scene:e.scene||1011};let P;a&&(q.path=a,S.path=a),u&&(q.query=querystring_1.default.parse(u)),S.debugLaunchInfo=JSON.stringify(q),a&&u&&(S.path+="?"+u),l&&c&&(S.bigPackageSizeSupport=1);let h={};try{P=await o.getFile(o.miniprogramRoot,"ext.json"),h=JSON.parse(P.toString("utf-8"))}catch(e){}if(h&&(h.extEnable&&(S.extAppId=h.extAppid),h.directCommit)){let e="";e=h.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.warn(e)}try{const e=new taskstatus_1.TaskStatus(locales_1.default.config.UPLOAD.toString());n(e);const t=`${l?url_config_1.TEST_SOURCE_URL:url_config_1.UPLOAD_URL}?${querystring_1.default.stringify(S)}`;let r,i=!1,a=0;const u=(0,pack_1.pack)(b),p=zlib_1.default.gzipSync(u.buffer);if(log.info("useCOS parameter: ",_),log.info("upload zip buffer size: ",p.length),void 0===_&&(_=p.length>5242880),_){log.info("upload by COS: ",_);const e=await(0,cos_upload_1.uploadByCos)(p,t,o,s);e.fallback?(i=e.fallback,log.info("upload by COS failed, fallback to http way")):(r={body:e.body},a=e.uploadCOSCostTime)}if(!_||i){const e=await(0,sign_1.getSignature)(o.privateKey,o.appid);b[exports.SIGNATURE_FILE_NAME]=JSON.stringify({signature:e,version:y});const i=(0,pack_1.pack)(b),s=zlib_1.default.gzipSync(i.buffer);log.info("request url:",t);const n=(await(0,request_1.request)({url:t,method:"post",body:s})).body.toString();if(r=(0,jsonParse_1.jsonRespParse)(n,t),0!==r.errCode)throw new Error(n)}e.done(),n(e);const c={respBody:r.body};if(Array.isArray(r.body.subpackage_info)){const e=r.body.subpackage_info;c.subPackageInfo=e}if(Array.isArray(r.body.ext_plugin_info)){const e=r.body.ext_plugin_info;c.pluginInfo=e.map(e=>({pluginProviderAppid:e.provider,version:e.version,size:e.size}))}return c}catch(e){throw new error_1.CodeError(e.toString(),config_1.UPLOAD_CGI_ERR)}}exports.upload=upload,exports.innerUpload=innerUpload;
|
package/dist/cli/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"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=tslib_1.__importStar(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 o(o){return{command:o,describe:o+" commands",builder:i=>i.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:i=>e=e=>ci.cloud["storage"===o?"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 o=await ci.packNpmManually({packageJsonPath:String(e.packNpmManuallyPackageJsonPath),miniprogramNpmDistDir:String(e.packNpmManuallyMiniprogramNpmDistDir),ignores:[]});log.log("pack npm done, pack result:",o)})()}}).command({command:"cloud",describe:"cloudbase commands",builder:i=>i.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",boolean:!0}).options("use-project-config",{describe:"enable transform from es6 to es5",default:!1,boolean:!0}).options("enable-es7",{describe:"enable transform from es7 to es5",boolean:!0}).options("enable-autoprefixwxss",{describe:"enable autoprefixwxss",boolean:!0}).options("enable-minify-wxss",{describe:"enable minify wxss",boolean:!0}).options("enable-minify-wxml",{describe:"enable minify wxml",boolean:!0}).options("enable-minify-js",{describe:"enable minify js",boolean:!0}).options("enable-minify",{describe:"enable minify js/wxml/wxss",boolean:!0}).options("enable-code-protect",{describe:"enable code protect",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 o=new ci.Project({appid:i.appid,projectPath:i.projectPath,privateKeyPath:i.privateKeyPath,type:i.projectType,ignores:i.projectIgnores});if(formatCompileSetting(i),e)await e(o);else if(i._.includes("upload"))await ci.upload({project:o,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,useProjectConfig:i.useProjectConfig},threads:i.threads,version:i.uploadVersion,desc:i.uploadDescription,robot:i.robot,onProgressUpdate:e=>{i.verbose&&log.log(""+e)}});else if(i._.includes("preview")){let e=i.scene;e&&(e=parseInt(e,10)),await ci.preview({project:o,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,useProjectConfig:i.useProjectConfig},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.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:o,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.log(""+e)},qrcodeFormat:i.qrcodeFormat,qrcodeOutputDest:i.qrcodeOutputDest},i.savePath)}else if(i._.includes("pack-npm")){const e=await ci.packNpm(o,{ignores:i.packNpmIgnores,reporter:e=>{i.verbose&&console.log(e)}})||[];e.length&&(log.log("Pack npm warning:"),log.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 if(i._.includes("get-dev-source-map"))await ci.getDevSourceMap({project:o,robot:parseInt(i.robot,10),sourceMapSavePath:i.sourceMapSavePath}),log.info(`save sourcemap.zip to ${i.sourceMapSavePath} successfully`);else if(i._.includes("check-code-quality")){const e=await ci.checkCodeQuality(o);i.savePath?(fs_extra_1.default.ensureDirSync(path_1.default.dirname(i.savePath)),fs_extra_1.default.writeFileSync(i.savePath,JSON.stringify(e)),log.info(`save json format report to ${i.savePath} successfully`)):console.log(e)}}}function formatCompileSetting(e){if(!0!==e.useProjectConfig)for(const o in e)void 0===e[o]&&(e[o]=!1)}run().catch(e=>{console.error(e),process.exit(1)});
|
|
1
|
+
"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=tslib_1.__importStar(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 o(o){return{command:o,describe:o+" commands",builder:i=>i.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:i=>e=e=>ci.cloud["storage"===o?"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 o=await ci.packNpmManually({packageJsonPath:String(e.packNpmManuallyPackageJsonPath),miniprogramNpmDistDir:String(e.packNpmManuallyMiniprogramNpmDistDir),ignores:[]});log.log("pack npm done, pack result:",o)})()}}).command({command:"cloud",describe:"cloudbase commands",builder:i=>i.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",boolean:!0}).options("use-project-config",{describe:"enable transform from es6 to es5",default:!1,boolean:!0}).options("enable-es7",{describe:"enable transform from es7 to es5",boolean:!0}).options("enable-autoprefixwxss",{describe:"enable autoprefixwxss",boolean:!0}).options("enable-minify-wxss",{describe:"enable minify wxss",boolean:!0}).options("enable-minify-wxml",{describe:"enable minify wxml",boolean:!0}).options("enable-minify-js",{describe:"enable minify js",boolean:!0}).options("enable-minify",{describe:"enable minify js/wxml/wxss",boolean:!0}).options("enable-code-protect",{describe:"enable code protect",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 o=new ci.Project({appid:i.appid,projectPath:i.projectPath,privateKeyPath:i.privateKeyPath,type:i.projectType,ignores:i.projectIgnores});if(formatCompileSetting(i),e)await e(o);else if(i._.includes("upload"))await ci.upload({project:o,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,useProjectConfig:i.useProjectConfig},threads:i.threads,version:i.uploadVersion,desc:i.uploadDescription,robot:i.robot,onProgressUpdate:e=>{i.verbose&&log.log(e)}});else if(i._.includes("preview")){let e=i.scene;e&&(e=parseInt(e,10)),await ci.preview({project:o,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,useProjectConfig:i.useProjectConfig},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.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:o,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.log(e)},qrcodeFormat:i.qrcodeFormat,qrcodeOutputDest:i.qrcodeOutputDest},i.savePath)}else if(i._.includes("pack-npm")){const e=await ci.packNpm(o,{ignores:i.packNpmIgnores,reporter:e=>{i.verbose&&console.log(e)}})||[];e.length&&(log.log("Pack npm warning:"),log.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 if(i._.includes("get-dev-source-map"))await ci.getDevSourceMap({project:o,robot:parseInt(i.robot,10),sourceMapSavePath:i.sourceMapSavePath}),log.info(`save sourcemap.zip to ${i.sourceMapSavePath} successfully`);else if(i._.includes("check-code-quality")){const e=await ci.checkCodeQuality(o);i.savePath?(fs_extra_1.default.ensureDirSync(path_1.default.dirname(i.savePath)),fs_extra_1.default.writeFileSync(i.savePath,JSON.stringify(e)),log.info(`save json format report to ${i.savePath} successfully`)):console.log(e)}}}function formatCompileSetting(e){if(!0!==e.useProjectConfig)for(const o in e)void 0===e[o]&&(e[o]=!1)}run().then(()=>{log.log("done"),process.exit(0)},e=>{console.error(e),process.exit(1)});
|
package/dist/config/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var COMPILE_TYPE,AstType;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=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="2.0.
|
|
1
|
+
"use strict";var COMPILE_TYPE,AstType;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=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="2.0.6",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(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.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"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSONWithDisableSpreading=exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),extJSON_1=require("../app/extJSON"),app_1=require("../app"),tools_1=require("../../../../../utils/tools"),common_1=require("../common"),common_2=require("../../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),checkPageJSON_1=require("./checkPageJSON"),spreadUsingComponent=e=>{const{project:o,pagePath:t,inputJSON:n}=e;if(t.includes("miniprogram_npm"))return;const a=(0,app_1.getAppJSON)(o);if((0,common_1.checkPagePathIsInIndependentSubpackage)(a,t))return;if(a.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in a.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||a.componentPlaceholder[e]}const i=Object.assign({},a.usingComponents);if(0!==Object.keys(i).length){n.usingComponents||(n.usingComponents={});for(const e in i){if(n.usingComponents[e])continue;const o=i[e]||"";if(o.startsWith("/")||o.startsWith("plugin://")){n.usingComponents[e]=o;continue}const a=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(t),o));n.usingComponents[e]=a.startsWith(".")?a:"./"+a}}},mergeExtJSON=e=>{var o;const{project:t,inputJSON:n,pagePath:a}=e,i=(0,extJSON_1.getExtJSON)(t);(null===(o=null==i?void 0:i.extPages)||void 0===o?void 0:o[a])&&Object.assign(n,i.extPages[a])},checkComponentPath=e=>{const{project:o,miniprogramRoot:t,pagePath:n,inputJSON:a}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:n+".json",inputJSON:a})},checkComponentGenerics=e=>{const{pagePath:o,inputJSON:t}=e,n=o+".json";if(!t.componentGenerics)return;const a=[];for(const e in t.componentGenerics){const o=t.componentGenerics[e],n=(0,tools_1.getType)(o);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(o.default)&&a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:n})};function checkRenderer(e){var o,t;const{filePath:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSONWithDisableSpreading=exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),extJSON_1=require("../app/extJSON"),app_1=require("../app"),tools_1=require("../../../../../utils/tools"),common_1=require("../common"),common_2=require("../../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),checkPageJSON_1=require("./checkPageJSON"),spreadUsingComponent=e=>{const{project:o,pagePath:t,inputJSON:n}=e;if(t.includes("miniprogram_npm"))return;const a=(0,app_1.getAppJSON)(o);if((0,common_1.checkPagePathIsInIndependentSubpackage)(a,t))return;if(a.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in a.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||a.componentPlaceholder[e]}const i=Object.assign({},a.usingComponents);if(0!==Object.keys(i).length){n.usingComponents||(n.usingComponents={});for(const e in i){if(n.usingComponents[e])continue;const o=i[e]||"";if(o.startsWith("/")||o.startsWith("plugin://")){n.usingComponents[e]=o;continue}const a=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(t),o));n.usingComponents[e]=a.startsWith(".")?a:"./"+a}}},mergeExtJSON=e=>{var o;const{project:t,inputJSON:n,pagePath:a}=e,i=(0,extJSON_1.getExtJSON)(t);(null===(o=null==i?void 0:i.extPages)||void 0===o?void 0:o[a])&&Object.assign(n,i.extPages[a])},checkComponentPath=e=>{const{project:o,miniprogramRoot:t,pagePath:n,inputJSON:a}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:n+".json",inputJSON:a})},checkComponentGenerics=e=>{const{pagePath:o,inputJSON:t}=e,n=o+".json";if(!t.componentGenerics)return;const a=[];for(const e in t.componentGenerics){const o=t.componentGenerics[e],n=(0,tools_1.getType)(o);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(o.default)&&a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:n})};function checkRenderer(e){var o,t,n;const{filePath:a,inputJSON:i}=e,{renderer:r}=i,c=(0,app_1.getAppJSON)(e.project);if((0,common_2.getAllPages)(c).includes(e.pagePath)&&("skyline"===r&&("requiredComponents"!==c.lazyCodeLoading&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format(a),filePath:a}),(null===(o=c.rendererOptions)||void 0===o?void 0:o.skyline)||(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_RENDEREROPTIONS.format(a),filePath:a})),"skyline"===r||"skyline"===c.renderer&&void 0===r)){"default"===i.navigationStyle&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(a),filePath:a});!(i.navigationStyle?"custom"===i.navigationStyle:"custom"===(null===(t=c.window)||void 0===t?void 0:t.navigationStyle))&&(i.navigationBarTitleText||i.navigationBarTextStyle||i.navigationBarBackgroundColor)&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(a),filePath:a}),i.disableScroll=null===(n=i.disableScroll)||void 0===n||n,i.navigationStyle="custom"}}function checkComponentFramework(e){const{filePath:o,inputJSON:t}=e,{renderer:n,componentFramework:a}=t,i=(0,app_1.getAppJSON)(e.project);if(!(0,common_2.getAllPages)(i).includes(e.pagePath))return;const r="skyline"===n||"skyline"===i.renderer&&void 0===n,c="glass-easel"===a||"glass-easel"===i.componentFramework&&void 0===a;r&&(c||(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_COMPONENTFRAMEWORK_SKYLINE.format(o),filePath:o}))}const compilePageJSON=(e,o=!1)=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),o||spreadUsingComponent(e),checkRenderer(e),checkComponentFramework(e)};function originGetPageJSON(e,o){const{pagePath:t,miniprogramRoot:n=""}=o,a=(0,tools_1.normalizePath)(path_1.default.posix.join(n,t+".json")),i=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),r=(0,lodash_1.cloneDeep)(i.getPageJSON("checked",o));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:r,filePath:a,pagePath:t}),r.usingComponents||(r.usingComponents={}),r}async function getPageJSON(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t).getPageJSON("compiled",o)}function getPageJSONWithDisableSpreading(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e),n=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t),{pagePath:a,miniprogramRoot:i=""}=o,r=(0,tools_1.normalizePath)(path_1.default.posix.join(i,a+".json")),c=(0,lodash_1.cloneDeep)(n.getPageJSON("checked",o));return compilePageJSON({project:t,miniprogramRoot:i,inputJSON:c,filePath:r,pagePath:a},!0),c.usingComponents||(c.usingComponents={}),c}exports.originGetPageJSON=originGetPageJSON,reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON),exports.getPageJSON=getPageJSON,exports.getPageJSONWithDisableSpreading=getPageJSONWithDisableSpreading;
|
package/dist/modules/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Builder=void 0;const index_1=require("./precompiler/index"),nativecompiler_1=require("./nativecompiler"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Builder=void 0;const index_1=require("./precompiler/index"),nativecompiler_1=require("./nativecompiler"),createSummer_1=require("./createSummer"),singletontask_1=require("../utils/singletontask");class Builder{constructor(e,t){this.originProject=e,this._options=t}async getCompiler(){return this.getSummerCompiler()}async getPreCompileProject(){if(!this._precompileProject){const{targetPlatform:e,targetPlatformDefines:t}=this._options,i=await this.getPreCompiler();this._precompileProject=await i.getPreCompileProject({targetPlatform:e,targetPlatformDefines:t,runEnv:"main process"}),await this._precompileProject.ready()}return this._precompileProject}async getPreCompiler(){if(!this._preCompiler){const{devtoolMessagehub:e}=this._options;this._preCompiler=new index_1.PreCompiler(this.originProject,e)}return this._preCompiler}async getSummerCompiler(){if(!this._summerCompiler){const{summerCompilerClass:e,projectInfo:t,cachePath:i="",devtoolMessagehub:r}=this._options,o=await this.getPreCompileProject();e?(this._summerCompiler=new e(o,i,t,r),await this._summerCompiler.ready()):this._summerCompiler=await(0,createSummer_1.getSummerCompiler)(o)}return this._summerCompiler}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this,this._options))),await this._checkReadyTask.getResult()}async init(){}async getNativeCompiler(){return this._nativeCompiler||await this.initNativeCompiler(this._options),this._nativeCompiler}async initNativeCompiler(e){if("multiPlatform"!==this.originProject.projectArchitecture)return;const{miniappDirPath:t,devtoolsVersion:i,devtoolMessagehub:r}=e;this._nativeCompiler=new nativecompiler_1.NativeCompiler({project:this._precompileProject,devtoolMessagehub:r,devtoolsVersion:i,miniappDirPath:t}),await this._nativeCompiler.ready()}getPreCompileOptions(){var e,t;return{targetPlatform:null===(e=this._precompileProject)||void 0===e?void 0:e.targetPlatform,targetPlatformDefines:null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatformDefines}}async changePreCompileOptions(e){var t;await this.getPreCompileProject(),(null===(t=this._precompileProject)||void 0===t?void 0:t.targetPlatform)!==e.targetPlatform&&(this._precompileProject.updateConditionCompileOptions(e),await new Promise(e=>setTimeout(e,500)))}async setLocale(e){(await this.getSummerCompiler()).setLocale(e)}destroy(){var e,t;(null===(e=this._summerCompiler)||void 0===e?void 0:e.isSummer)&&this._summerCompiler.destroy(),null===(t=this._nativeCompiler)||void 0===t||t.destroy()}}exports.Builder=Builder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NativeCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),define_1=require("../../config/define"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask");class NativeCompiler{constructor(s){this.initedPromise=null,this.onProgressUpdate=(s,e,i)=>{const t="doing"===e?"doing":"done"===e?"success":"error";this.messageHub.showBuildLog(""+s,t,i)},this.messageHub=new messageHub_1.MessageHub(s.devtoolMessagehub),this.project=s.project,this.miniappDirPath=s.miniappDirPath,this.devtoolsVersion=s.devtoolsVersion}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this))),await this._checkReadyTask.getResult()}async init(){return this.initedPromise||(this.initedPromise=(async()=>{await this.createSubProcessManager()})()),this.initedPromise}async createSubProcessManager(){const s=path_1.default.posix.join(__dirname,"./nativeEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,s,{miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion},{},8892)}async runAndroid(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async runIOS(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidAPK(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSIPA(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidPlugin(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSPlugin(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async packIOSCloudBuildMaterial(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("packIOSCloudBuildMaterial",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}destroy(){this.subProcessManager.destroy()}}exports.NativeCompiler=NativeCompiler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NativeCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),define_1=require("../../config/define"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask");class NativeCompiler{constructor(s){this.initedPromise=null,this.onProgressUpdate=(s,e,i)=>{const t="doing"===e?"doing":"done"===e?"success":"error";this.messageHub.showBuildLog(""+s,t,i)},this.messageHub=new messageHub_1.MessageHub(s.devtoolMessagehub),this.project=s.project,this.miniappDirPath=s.miniappDirPath,this.devtoolsVersion=s.devtoolsVersion}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this))),await this._checkReadyTask.getResult()}async init(){return this.initedPromise||(this.initedPromise=(async()=>{await this.createSubProcessManager()})()),this.initedPromise}async createSubProcessManager(){const s=path_1.default.posix.join(__dirname,"./nativeEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,s,{miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion},{},8892)}async runAndroid(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async runIOS(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidAPK(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSIPA(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async codesignIpa(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("codesignIOSApp",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidPlugin(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSPlugin(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async packIOSCloudBuildMaterial(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("packIOSCloudBuildMaterial",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}destroy(){this.subProcessManager.destroy()}}exports.NativeCompiler=NativeCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.printFoundDevices=exports.formattedDeviceName=exports.matchingDevice=exports.findMatchingSimulator=exports.getDevices=exports.parseXctraceIOSDevicesList=void 0;const tslib_1=require("tslib"),execa=tslib_1.__importStar(require("execa")),env_1=require("../../../utils/env"),miniappBuilder=tslib_1.__importStar(require("../../../utils/miniapp-builder"));function parseIOSDevicesList(e){const i=[];return e.split("\n").forEach(e=>{const t=e.match(/(.*?) (\(([0-9.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);if(t){const[,e,,r,n,s]=t,c={name:e,udid:n};r?(c.version=r,c.type=s?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}function parseXctraceIOSDevicesList(e){const i=[];let t=!1;return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.printFoundDevices=exports.formattedDeviceName=exports.matchingDevice=exports.findMatchingSimulator=exports.getDevices=exports.parseXctraceIOSDevicesList=void 0;const tslib_1=require("tslib"),execa=tslib_1.__importStar(require("execa")),env_1=require("../../../utils/env"),miniappBuilder=tslib_1.__importStar(require("../../../utils/miniapp-builder"));function parseIOSDevicesList(e){const i=[];return e.split("\n").forEach(e=>{const t=e.match(/(.*?) (\(([0-9.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);if(t){const[,e,,r,n,s]=t,c={name:e,udid:n};r?(c.version=r,c.type=s?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}function parseXctraceIOSDevicesList(e){const i=[];let t=!1;return e.split("\n").forEach(e=>{"== Simulators =="===e&&(t=!0);const r=e.match(/^(.*?) (\(([0-9.]{3,})\) )?\(([0-9A-F-]{5,})\)$/i);if(r){const[,e,,n,s]=r,c={name:e,udid:s};n?(c.version=n,c.type=t?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}async function getDevices(e){let i=[];const{recorder:t}=e||{};try{const e=await execa.default("xcrun",["xctrace","list","devices"],{env:(0,env_1.getProcessEnv)()});i=parseXctraceIOSDevicesList(""===e.stderr?e.stdout:e.stderr)}catch(e){try{i=parseIOSDevicesList(execa.sync("xcrun",["instruments","-s"],{env:(0,env_1.getProcessEnv)()}).stdout)}catch(e){}}let r=i.filter(e=>"device"===e.type);if(!r.length)try{r=await miniappBuilder.getIOSDevices(e||{}),r.forEach(e=>{i.find(i=>i.udid===e.udid)||i.push(e)})}catch(e){t?t.progress("get Devices error:"+e.message):console.error("get Devices error:",e)}return i.filter(e=>!!e.version)}function findMatchingSimulator(e,i){if(!e.devices)return null;const{devices:t}=e;let r,n,s=null;if(null==i?void 0:i.device){const e=i.device.match(/(.*)? (?:\((\d+\.\d+)?\))$/);void 0!==(null==e?void 0:e[2])?(r=e[2],s=e[1]):s=i.device}for(const e in t){const c=t[e];let o=e;if(o.startsWith("com.apple.CoreSimulator.SimRuntime.")&&(o=o.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g,"$1 $2.$3")),(o.includes("iOS")||o.includes("tvOS"))&&(!r||o.endsWith(r)))for(const e of c){if("(available)"!==e.availability&&"YES"!==e.isAvailable&&!0!==e.isAvailable)continue;const t="Booted"===e.state,r={udid:e.udid,name:e.name,booted:t,version:o};if(null==i?void 0:i.udid){if(e.udid===i.udid)return r}else{if(t&&null===s)return r;e.name!==s||n||(n=r)}}}return n}function matchingDevice(e,i,t){if(!0===i){const i=e.find(e=>"device"===e.type);return i?(t.progress(`Using first available device named "${i.name}" due to lack of name supplied.`),i):void t.progress("No iOS devices connected.")}const r=e.find(e=>e.name===i||formattedDeviceName(e)===i);if(!r)throw new Error(`Could not find a device named: "${String(i)} ${printFoundDevices(e)}}".`);return r}function formattedDeviceName(e){return e.version?`${e.name} (${e.version})`:e.name}function printFoundDevices(e){return["Available devices:",...e.map(e=>` - ${e.name} (${e.udid})`)].join("\n")}exports.parseXctraceIOSDevicesList=parseXctraceIOSDevicesList,exports.getDevices=getDevices,exports.findMatchingSimulator=findMatchingSimulator,exports.matchingDevice=matchingDevice,exports.formattedDeviceName=formattedDeviceName,exports.printFoundDevices=printFoundDevices;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IOSUtils=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),env_1=require("../../../utils/env"),deviceUtils=tslib_1.__importStar(require("./device")),projectConfigUtils=tslib_1.__importStar(require("./projectconfig")),cp_1=require("../../../utils/cp"),miniapp_builder_1=require("../../../utils/miniapp-builder"),miniappJson_1=require("../../../utils/miniappJson"),singletontask_1=require("../../../utils/singletontask"),buildCloud_1=tslib_1.__importStar(require("./buildCloud")),tools_1=require("../../../utils/tools"),ProjectMiniappJsonSplashScreenThemeKey="__splashscreenTheme",_iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}},_allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"],_getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),buildIOSPluginTask={};class IOSUtils{constructor(e,i={},t,n){this.root=e,this.userConfig=i,this.miniappDirPath=t,this.devtoolsVersion=n}getProjectConfig(){const e=projectConfigUtils.getProjectConfig(this.root,this.userConfig);if(!e)throw new Error("iOS project folder not found. Are you sure this is a miniapp project?");return e}getBundleId(e){return child_process.execFileSync("/usr/libexec/PlistBuddy",["-c","Print:CFBundleIdentifier",path_1.default.join(e,"Info.plist")],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim()}tryInstallPod(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t,o={cwd:n,env:(0,env_1.getProcessEnv)()};i.progress("export LANG=en_US.UTF-8 && pod install"),child_process.execSync("export LANG=en_US.UTF-8 && pod install",o)}async runLocal(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t;process.chdir(n),this.tryInstallPod(e,i);const o=path_1.default.basename(t.name,path_1.default.extname(t.name)),a=e.scheme||o;if(i.progress(`Found Xcode ${t.isWorkspace?"workspace":"project"} "${t.name}"`),e.device||e.udid){if(e.udid||e.device){const n=await deviceUtils.getDevices({recorder:i}),o=n.find(i=>i.udid===e.udid||i.name===e.device);if(!o)throw new Error(`Could not find a device with udid(${e.udid}) or device(${e.device}). ${deviceUtils.printFoundDevices(n)}`);if("simulator"===o.type)return void await this.runOnSimulatorLocal(t,a,e,i);await this.runOnDeviceLocal(t,a,o,i)}}else await this.runOnSimulatorLocal(t,a,e,i)}async runCloud(e,i){try{const{deviceType:t,udid:n,projectPath:o,demoIpaPath:a,sdkPath:s,bindingInfo:r,certificateInfo:c,arch:l="arm64",pluginDirList:d,miniappCacheDirPath:p,theme:u,i18nInfo:h}=e,f=buildCloud_1.default.generateTempDemoIpaPath(a),_="simulator"===t,m=(0,miniappJson_1.tryGetIOSMiniappJson)(o);let g=r;if(c.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=g;g=Object.assign(Object.assign({},g),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const b=await buildCloud_1.default.updateIOSInfoPlistInfo(o,g,f,m,i,h);await buildCloud_1.default.updateIOSAppConfigPlistInfo(o,g,f,m,s,_,i,u,h),await buildCloud_1.default.updateIOSAppexInfoPlistInfo(g,f,m,b,i),await buildCloud_1.default.updateIOSIcons(o,f,"",m,!1,i),await buildCloud_1.default.updateSplashScreen(o,f,m,i,u),await buildCloud_1.default.updateExtendedSdk(g,f,s,l,m,i),await buildCloud_1.default.updatePlugin(f,d,o,m,p,!1,b,i);const v=await buildCloud_1.default.getEntitlements(g,f,m,i);if("device"===t){const{mobileapp_info:e={}}=g,t=e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id;await(0,miniapp_builder_1.signAndInstallOrExport)(o,f,p,c,{bundleId:t,install:!0,deviceId:n,entitlements:v},{recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion})}else await this.runOnSimulatorCloud(f,{udid:n},i)}catch(e){throw new Error("Run the app failed:"+e.message)}}async buildLocal(e,i){const t=this.getProjectConfig();process.chdir(t.sourceDir);const n=path_1.default.basename(t.name,path_1.default.extname(t.name)),o=e.scheme||n;this.tryInstallPod(e,i),i.progress("start build ipa...");const a=await this.buildProjectArchive(t,{output:e.output,scheme:o},i),s=await this.exportArchive(t,a,e,i);return console.log("Successfully build ipa: "+s),s}async buildCloud(e,i){try{const{projectPath:t,certificateInfo:n,miniappCacheDirPath:o}=e,a=await buildCloud_1.default.buildCloud(e,i),{demoIpaPath:s,opts:r}=a,c={recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion};a.isPublish||await(0,miniapp_builder_1.signAndInstallOrExport)(t,s,o,n,r,c)}catch(e){throw new Error("Build ipa failed:"+e.message)}}async genProjectMaterialMap(e,i,t,n){var o,a;const s=buildCloud_1.remoteBuildProjectMaterialAbsoluteCacheDir,r=path_1.default.join(i,s),c=(0,miniappJson_1.tryGetIOSMiniappJson)(e);function l(e,i){fs_extra_1.default.ensureDirSync(path_1.default.dirname(i)),fs_extra_1.default.copyFileSync(e,i)}function d(t,n,o=!0){if(!n){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}if(path_1.default.isAbsolute(n)){const e=path_1.default.basename(n);if(!fs_extra_1.default.existsSync(n)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}const i=(0,tools_1.generateMD5)(n);return l(n,path_1.default.join(r,`${i}_${e}`)),path_1.default.join(s,e)}const a=path_1.default.join(e,n),c=path_1.default.join(i,n);if(!fs_extra_1.default.existsSync(a)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}return l(a,c),n}fs_extra_1.default.ensureDirSync(r);const{privacy:p={},icons:u={},splashscreen:h={},buildCloud:f={}}=c,_=d("project.miniapp.json","project.miniapp.json",!1),m=d("project.config.json","project.config.json",!1),g=(0,miniappJson_1.getMiniprogramRoot)(e),b=d("app.json",path_1.default.join(g,"app.json"),!1),{template:v,contentViewImage:y,cancelButtonImage:S,confirmButtonImage:w}=p,P=d("privacy template",v),I=d("privacy contentViewImage",y),x=d("privacy cancelButtonImage",S),j=d("privacy confirmButtonImage",w),E=[];for(const e in u)if(u[e]){const i=d("icons."+e,u[e],!1);i&&E.push(i)}const O=d("splashscreen.customImage",h.customImage),{p12:D,profile:C,tpnsProfile:A}=f,$=d("p12 Path",D,!1),T=d("profile Path",C,!1);let k=void 0;!0===(null===(o=null==c?void 0:c.tpush)||void 0===o?void 0:o.useExtendedLib_WeAppTPNS)&&(k=d("tpns profile Path",A,!0!==(null===(a=null==c?void 0:c.tpush)||void 0===a?void 0:a.useExtendedLib_WeAppTPNS)));const B="miniapp/ios/i18nInfo.json",F=path_1.default.join(e,B),U=d("i18n",B,!0);if(fs_extra_1.default.existsSync(F)){const i=function(e,i){function t(i,t,n){if(t[n]&&"object"==typeof t[n][i])for(const o in t[n][i])if("object"==typeof t[n][i]){const a=t[n][i][o];if("string"==typeof a&&a.length>0){fs_extra_1.default.existsSync(path_1.default.isAbsolute(a)?a:path_1.default.join(e,a))&&d(`i18nFiles.${n}.${o}`,a,!0)}}}try{const n=fs_extra_1.default.readJSONSync(path_1.default.join(e,i));for(const e in n)t("ios",n,e),t("android",n,e)}catch(e){return e.message}}(e,B);if(i)throw n.message("fail",i),new Error("copyi18NFiles error "+i)}const L=path_1.default.join(i,"project.miniapp.json");try{const e=fs_extra_1.default.readJsonSync(L);let{theme:i}=t;t.theme||(i="Dark"),e.__splashscreenTheme=i,fs_extra_1.default.writeJSONSync(L,e)}catch(e){throw new Error(`ReadWriteJsonFailed projectMiniappJsonCacheFilePath: ${L},error ${e.message}`)}const M=c["mini-plugin"];return M&&Array.isArray(M.ios)&&M.ios.forEach(e=>{!0===e.open&&e.resourcePath&&d(`mini-plugin ios ${e.pluginId}:${e.resourcePath}`,e.resourcePath)}),{projectMiniappJson:_,projectConfigJson:m,appJson:b,privacyJson:P,privacyContentViewImage:I,privacyCancelButtonImage:x,privacyConfirmButtonImage:j,icons:E,splashScreen:O,p12:$,profile:T,tpnsProfile:k,i18nJson:U}}async packIOSCloudBuildMaterial(e,i){i.progress("start uploadProjectAllMaterial");const{projectPath:t,matrialDistPath:n,theme:o}=e;await this.genProjectMaterialMap(t,n,e,i);i.progress("packIOSCloudBuildMaterial done")}launchSimulator(e,i){let t;try{t=JSON.parse(child_process.execFileSync("xcrun",["simctl","list","--json","devices"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}))}catch(e){throw new Error("Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues."+e.message)}const n=["iPhone 13","iPhone 12","iPhone 11"].reduce((e,i)=>e||deviceUtils.findMatchingSimulator(t,{device:i}),deviceUtils.findMatchingSimulator(t,e));if(!n)throw new Error("No simulator available with "+(e.device?`name "${e.device}"`:`udid "${e.udid}"`));const o=child_process.execFileSync("xcode-select",["-p"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim();if(child_process.execFileSync("open",[o+"/Applications/Simulator.app","--args","-CurrentDeviceUDID",n.udid],{env:(0,env_1.getProcessEnv)()}),!n.booted){const e=deviceUtils.formattedDeviceName(n);i.progress("Launching "+e),child_process.spawnSync("xcrun",["simctl","boot",n.udid],{env:(0,env_1.getProcessEnv)()})}return n}async runOnSimulatorCloud(e,i,t){const{udid:n}=i,o=this.launchSimulator({udid:n},t);await this.installAppOnSimulator(o,e,t),await this.launchAppOnSimulator(o,e,t)}async runOnSimulatorLocal(e,i,t,n){const o=this.launchSimulator(t,n),{appPath:a}=await this.buildProjectApp(e,{udid:o.udid,scheme:i},n);await this.installAppOnSimulator(o,a,n),await this.launchAppOnSimulator(o,a,n)}async runOnDeviceLocal(e,i,t,n){const{appPath:o}=await this.buildProjectApp(e,{udid:t.udid,scheme:i},n);if("catalyst"===t.type){child_process.spawn(`${o}/${i}`,[],{detached:!0,stdio:"ignore",env:(0,env_1.getProcessEnv)()}).unref()}else{const e=["--bundle",o,"--id",t.udid,"--justlaunch"];n.progress("Installing and launching your app on "+t.name);const i=path_1.default.join(__dirname,"../../../vendor/ios-deploy/ios-deploy");await(0,cp_1.spawnSync)(i,e,{},n)}return n.progress("Install successfully the app to the device.")}buildProjectApp(e,i,t){return new Promise((n,o)=>{const{scheme:a,udid:s}=i,r=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",a];let c;s&&r.push("-destination","id="+s),t.progress(`Building (using "xcodebuild ${r.join(" ")}")`),this.xcbeautifyAvailable()?c=child_process.spawn("xcbeautify",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}):this.xcprettyAvailable()&&(c=child_process.spawn("xcpretty",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}));const l=child_process.spawn("xcodebuild",r,{env:(0,env_1.getProcessEnv)()});let d="",p="";l.stdout.on("data",e=>{const i=e.toString();t.progress(i),d+=i,c&&c.stdin.write(e)}),l.stderr.on("data",e=>{const i=e.toString();p+=i,t.progress(i)}),l.on("close",i=>{if(c&&c.stdin.end(),0!==i)return void o(new Error(` Failed to build iOS project.\n We ran "xcodebuild" command but it exited with error code ${i}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n ${c?void 0:`${d}\n${p}`}\n `));let s;try{s=this.getBuildInfo(e,d,a)}catch(e){o(e)}t.progress("Successfully built the app"),n(s)})})}async installAppOnSimulator(e,i,t){const n=["simctl","install",e.udid,i];await(0,cp_1.spawnSync)("xcrun",n,{},t)}async launchAppOnSimulator(e,i,t){const n=this.getBundleId(i),o=["simctl","launch",e.udid,n];await(0,cp_1.spawnSync)("xcrun",o,{},t),t.progress("Successfully launched the app on the simulator")}async buildProjectArchive(e,i,t){const{output:n,scheme:o,udid:a}=i,s=path_1.default.join(n,"./app"),{sourceDir:r}=e;fs_extra_1.default.ensureDirSync(path_1.default.dirname(s));const c=["archive",e.isWorkspace?"-workspace":"-project",e.name,"-scheme",o,"-archivePath",s];a&&c.push("-destination","id="+a);try{if(await(0,cp_1.spawnSync)("xcodebuild",c,{cwd:r},t),!fs_extra_1.default.existsSync(s+".xcarchive"))throw new Error(`Failed to build iOS project.\n ${s+".xcarchive"} does not found\n `);return t.progress(`Successfully archive the app: ${s}.xcarchive`),s+".xcarchive"}catch(i){throw new Error(`Failed to build iOS project. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}}async exportArchive(e,i,t,n){const o=path_1.default.join(t.output,"ipa");fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.emptyDirSync(o);const{exportOptionPlistPath:a}=t;if(!a)throw new Error("build ios ipa require exportOptionPlistPath in project.miniapp.json");let s="";s=path_1.default.isAbsolute(a)?a:path_1.default.join(t.projectPath,a);const r=["-exportArchive","-archivePath",i,"-exportOptionsPlist",s,"-exportPath",o];try{await(0,cp_1.spawnSync)("xcodebuild",r,{cwd:e.sourceDir},n)}catch(i){throw new Error(`To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}return fs_extra_1.default.removeSync(i),o}getTargetPaths(e){const i=JSON.parse(e);for(const e in i){if("app"===i[e].buildSettings.WRAPPER_EXTENSION)return{targetBuildDir:i[e].buildSettings.TARGET_BUILD_DIR,executableFolderPath:i[e].buildSettings.EXECUTABLE_FOLDER_PATH}}return{}}getBuildInfo(e,i,t){const n=this.getPlatformName(i),o=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",t,"-sdk",n,"-showBuildSettings","-json"].join(" "),a=child_process.execSync("xcodebuild "+o,{encoding:"utf8",cwd:e.sourceDir,env:(0,env_1.getProcessEnv)()}),s=this.getBuildProductDir(i),{executableFolderPath:r}=this.getTargetPaths(a);if(!r)throw new Error("Failed to get the app name.");return{sdk:n,appPath:`${s}/${r}`}}getPlatformName(e){const i=/export PLATFORM_NAME\\?="?(\w+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find PLATFORM_NAME in xcodebuild output.");return i[1]}getBuildProductDir(e){const i=/export BUILT_PRODUCTS_DIR\\?="?(.+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find BUILT_PRODUCTS_DIR in xcodebuild output.");return i[1]}xcbeautifyAvailable(){try{child_process.execSync("xcbeautify --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}xcprettyAvailable(){try{child_process.execSync("xcpretty --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}async buildPlugin(e,i){const{pluginId:t,projectPath:n,buildShellPath:o}=e;i.progress("start build native plugin...");try{const e=[n,t];fs_extra_1.default.chmodSync(o,"777"),buildIOSPluginTask[t]?(i.message("fail","存在未结束的插件构建任务,需等待构建结束..."),await buildIOSPluginTask[t].getResult(!0)):(buildIOSPluginTask[t]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,o,e,{},i)),await buildIOSPluginTask[t].getResult(!0),buildIOSPluginTask[t]=void 0)}catch(e){throw buildIOSPluginTask[t]=void 0,new Error("build plugin failed: "+e)}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let o="";Object.keys(t).forEach(e=>{var a,s,r,c;(null===(s=null===(a=i[n])||void 0===a?void 0:a.ios)||void 0===s?void 0:s[t[e]])&&(o+=`${e} = "${null===(c=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===c?void 0:c[t[e]]}";\n`)}),o&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),o))})}}exports.IOSUtils=IOSUtils;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IOSUtils=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),env_1=require("../../../utils/env"),deviceUtils=tslib_1.__importStar(require("./device")),projectConfigUtils=tslib_1.__importStar(require("./projectconfig")),cp_1=require("../../../utils/cp"),miniapp_builder_1=require("../../../utils/miniapp-builder"),miniappJson_1=require("../../../utils/miniappJson"),singletontask_1=require("../../../utils/singletontask"),buildCloud_1=tslib_1.__importStar(require("./buildCloud")),tools_1=require("../../../utils/tools"),codesign_1=require("../../../utils/codesign"),ProjectMiniappJsonSplashScreenThemeKey="__splashscreenTheme",_iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}},_allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"],_getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),buildIOSPluginTask={};class IOSUtils{constructor(e,i={},t,n){this.root=e,this.userConfig=i,this.miniappDirPath=t,this.devtoolsVersion=n}getProjectConfig(){const e=projectConfigUtils.getProjectConfig(this.root,this.userConfig);if(!e)throw new Error("iOS project folder not found. Are you sure this is a miniapp project?");return e}getBundleId(e){return child_process.execFileSync("/usr/libexec/PlistBuddy",["-c","Print:CFBundleIdentifier",path_1.default.join(e,"Info.plist")],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim()}tryInstallPod(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t,o={cwd:n,env:(0,env_1.getProcessEnv)()};i.progress("export LANG=en_US.UTF-8 && pod install"),child_process.execSync("export LANG=en_US.UTF-8 && pod install",o)}async runLocal(e,i){const t=this.getProjectConfig(),{sourceDir:n}=t;process.chdir(n),this.tryInstallPod(e,i);const o=path_1.default.basename(t.name,path_1.default.extname(t.name)),s=e.scheme||o;if(i.progress(`Found Xcode ${t.isWorkspace?"workspace":"project"} "${t.name}"`),e.device||e.udid){if(e.udid||e.device){const n=await deviceUtils.getDevices({recorder:i}),o=n.find(i=>i.udid===e.udid||i.name===e.device);if(!o)throw new Error(`Could not find a device with udid(${e.udid}) or device(${e.device}). ${deviceUtils.printFoundDevices(n)}`);if("simulator"===o.type)return void await this.runOnSimulatorLocal(t,s,e,i);await this.runOnDeviceLocal(t,s,o,i)}}else await this.runOnSimulatorLocal(t,s,e,i)}async runCloud(e,i){try{const{deviceType:t,udid:n,projectPath:o,demoIpaPath:s,sdkPath:a,bindingInfo:r,certificateInfo:c,arch:l="arm64",pluginDirList:d,miniappCacheDirPath:p,theme:u,i18nInfo:h}=e,f=buildCloud_1.default.generateTempDemoIpaPath(s),_="simulator"===t,m=(0,miniappJson_1.tryGetIOSMiniappJson)(o);let g=r;if(c.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=g;g=Object.assign(Object.assign({},g),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const b=await buildCloud_1.default.updateIOSInfoPlistInfo(o,g,f,m,i,h);await buildCloud_1.default.updateIOSAppConfigPlistInfo(o,g,f,m,a,_,i,u,h),await buildCloud_1.default.updateIOSAppexInfoPlistInfo(g,f,m,b,i),await buildCloud_1.default.updateIOSIcons(o,f,"",m,!1,i),await buildCloud_1.default.updateSplashScreen(o,f,m,i,u),await buildCloud_1.default.updateExtendedSdk(g,f,a,l,m,i),await buildCloud_1.default.updatePlugin(f,d,o,m,p,!1,b,i);const v=await buildCloud_1.default.getEntitlements(g,f,m,i);if("device"===t){const{mobileapp_info:e={}}=g,t=e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id;await(0,miniapp_builder_1.signAndInstallOrExport)(o,f,p,c,{bundleId:t,install:!0,deviceId:n,entitlements:v},{recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion})}else await this.runOnSimulatorCloud(f,{udid:n},i)}catch(e){throw new Error("Run the app failed:"+e.message)}}async buildLocal(e,i){const t=this.getProjectConfig();process.chdir(t.sourceDir);const n=path_1.default.basename(t.name,path_1.default.extname(t.name)),o=e.scheme||n;this.tryInstallPod(e,i),i.progress("start build ipa...");const s=await this.buildProjectArchive(t,{output:e.output,scheme:o},i),a=await this.exportArchive(t,s,e,i);return console.log("Successfully build ipa: "+a),a}async buildCloud(e,i){try{const{projectPath:t,certificateInfo:n,miniappCacheDirPath:o}=e,s=await buildCloud_1.default.buildCloud(e,i),{demoIpaPath:a,opts:r}=s,c={recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion};s.isPublish||await(0,miniapp_builder_1.signAndInstallOrExport)(t,a,o,n,r,c)}catch(e){throw new Error("Build ipa failed:"+e.message)}}async genProjectMaterialMap(e,i,t,n){var o,s;const a=buildCloud_1.remoteBuildProjectMaterialAbsoluteCacheDir,r=path_1.default.join(i,a),c=(0,miniappJson_1.tryGetIOSMiniappJson)(e);function l(e,i){fs_extra_1.default.ensureDirSync(path_1.default.dirname(i)),fs_extra_1.default.copyFileSync(e,i)}function d(t,n,o=!0){if(!n){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}if(path_1.default.isAbsolute(n)){const e=path_1.default.basename(n);if(!fs_extra_1.default.existsSync(n)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}const i=(0,tools_1.generateMD5)(n);return l(n,path_1.default.join(r,`${i}_${e}`)),path_1.default.join(a,e)}const s=path_1.default.join(e,n),c=path_1.default.join(i,n);if(!fs_extra_1.default.existsSync(s)){if(o)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}return l(s,c),n}fs_extra_1.default.ensureDirSync(r);const{privacy:p={},icons:u={},splashscreen:h={},buildCloud:f={}}=c,_=d("project.miniapp.json","project.miniapp.json",!1),m=d("project.config.json","project.config.json",!1),g=(0,miniappJson_1.getMiniprogramRoot)(e),b=d("app.json",path_1.default.join(g,"app.json"),!1),{template:v,contentViewImage:y,cancelButtonImage:S,confirmButtonImage:w}=p,P=d("privacy template",v),I=d("privacy contentViewImage",y),x=d("privacy cancelButtonImage",S),j=d("privacy confirmButtonImage",w),E=[];for(const e in u)if(u[e]){const i=d("icons."+e,u[e],!1);i&&E.push(i)}const O=d("splashscreen.customImage",h.customImage),{p12:D,profile:C,tpnsProfile:A}=f,$=d("p12 Path",D,!1),T=d("profile Path",C,!1);let k=void 0;!0===(null===(o=null==c?void 0:c.tpush)||void 0===o?void 0:o.useExtendedLib_WeAppTPNS)&&(k=d("tpns profile Path",A,!0!==(null===(s=null==c?void 0:c.tpush)||void 0===s?void 0:s.useExtendedLib_WeAppTPNS)));const B="miniapp/ios/i18nInfo.json",U=path_1.default.join(e,B),F=d("i18n",B,!0);if(fs_extra_1.default.existsSync(U)){const i=function(e,i){function t(i,t,n){if(t[n]&&"object"==typeof t[n][i])for(const o in t[n][i])if("object"==typeof t[n][i]){const s=t[n][i][o];if("string"==typeof s&&s.length>0){fs_extra_1.default.existsSync(path_1.default.isAbsolute(s)?s:path_1.default.join(e,s))&&d(`i18nFiles.${n}.${o}`,s,!0)}}}try{const n=fs_extra_1.default.readJSONSync(path_1.default.join(e,i));for(const e in n)t("ios",n,e),t("android",n,e)}catch(e){return e.message}}(e,B);if(i)throw n.message("fail",i),new Error("copyi18NFiles error "+i)}const L=path_1.default.join(i,"project.miniapp.json");try{const e=fs_extra_1.default.readJsonSync(L);let{theme:i}=t;t.theme||(i="Dark"),e.__splashscreenTheme=i,fs_extra_1.default.writeJSONSync(L,e)}catch(e){throw new Error(`ReadWriteJsonFailed projectMiniappJsonCacheFilePath: ${L},error ${e.message}`)}const M=c["mini-plugin"];return M&&Array.isArray(M.ios)&&M.ios.forEach(e=>{!0===e.open&&e.resourcePath&&d(`mini-plugin ios ${e.pluginId}:${e.resourcePath}`,e.resourcePath)}),{projectMiniappJson:_,projectConfigJson:m,appJson:b,privacyJson:P,privacyContentViewImage:I,privacyCancelButtonImage:x,privacyConfirmButtonImage:j,icons:E,splashScreen:O,p12:$,profile:T,tpnsProfile:k,i18nJson:F}}async codesignIOSApp(e,i){const{projectPath:t,demoIpaPath:n,opts:o}=e,s=await(0,codesign_1.codesignAndExport)(t,n,e.miniappCacheDir||"",o,i,e.isUsingTpush,!1,!0);if(!0!==s.success)throw new Error("Build ipa failed:"+(s.errMsg||"codesignAndExport failed"))}async packIOSCloudBuildMaterial(e,i){i.progress("start uploadProjectAllMaterial");const{projectPath:t,matrialDistPath:n,theme:o}=e;await this.genProjectMaterialMap(t,n,e,i);i.progress("packIOSCloudBuildMaterial done")}launchSimulator(e,i){let t;try{t=JSON.parse(child_process.execFileSync("xcrun",["simctl","list","--json","devices"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}))}catch(e){throw new Error("Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues."+e.message)}const n=["iPhone 13","iPhone 12","iPhone 11"].reduce((e,i)=>e||deviceUtils.findMatchingSimulator(t,{device:i}),deviceUtils.findMatchingSimulator(t,e));if(!n)throw new Error("No simulator available with "+(e.device?`name "${e.device}"`:`udid "${e.udid}"`));const o=child_process.execFileSync("xcode-select",["-p"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim();if(child_process.execFileSync("open",[o+"/Applications/Simulator.app","--args","-CurrentDeviceUDID",n.udid],{env:(0,env_1.getProcessEnv)()}),!n.booted){const e=deviceUtils.formattedDeviceName(n);i.progress("Launching "+e),child_process.spawnSync("xcrun",["simctl","boot",n.udid],{env:(0,env_1.getProcessEnv)()})}return n}async runOnSimulatorCloud(e,i,t){const{udid:n}=i,o=this.launchSimulator({udid:n},t);await this.installAppOnSimulator(o,e,t),await this.launchAppOnSimulator(o,e,t)}async runOnSimulatorLocal(e,i,t,n){const o=this.launchSimulator(t,n),{appPath:s}=await this.buildProjectApp(e,{udid:o.udid,scheme:i},n);await this.installAppOnSimulator(o,s,n),await this.launchAppOnSimulator(o,s,n)}async runOnDeviceLocal(e,i,t,n){const{appPath:o}=await this.buildProjectApp(e,{udid:t.udid,scheme:i},n);if("catalyst"===t.type){child_process.spawn(`${o}/${i}`,[],{detached:!0,stdio:"ignore",env:(0,env_1.getProcessEnv)()}).unref()}else{const e=["--bundle",o,"--id",t.udid,"--justlaunch"];n.progress("Installing and launching your app on "+t.name);const i=path_1.default.join(__dirname,"../../../vendor/ios-deploy/ios-deploy");await(0,cp_1.spawnSync)(i,e,{},n)}return n.progress("Install successfully the app to the device.")}buildProjectApp(e,i,t){return new Promise((n,o)=>{const{scheme:s,udid:a}=i,r=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",s];let c;a&&r.push("-destination","id="+a),t.progress(`Building (using "xcodebuild ${r.join(" ")}")`),this.xcbeautifyAvailable()?c=child_process.spawn("xcbeautify",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}):this.xcprettyAvailable()&&(c=child_process.spawn("xcpretty",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}));const l=child_process.spawn("xcodebuild",r,{env:(0,env_1.getProcessEnv)()});let d="",p="";l.stdout.on("data",e=>{const i=e.toString();t.progress(i),d+=i,c&&c.stdin.write(e)}),l.stderr.on("data",e=>{const i=e.toString();p+=i,t.progress(i)}),l.on("close",i=>{if(c&&c.stdin.end(),0!==i)return void o(new Error(` Failed to build iOS project.\n We ran "xcodebuild" command but it exited with error code ${i}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n ${c?void 0:`${d}\n${p}`}\n `));let a;try{a=this.getBuildInfo(e,d,s)}catch(e){o(e)}t.progress("Successfully built the app"),n(a)})})}async installAppOnSimulator(e,i,t){const n=["simctl","install",e.udid,i];await(0,cp_1.spawnSync)("xcrun",n,{},t)}async launchAppOnSimulator(e,i,t){const n=this.getBundleId(i),o=["simctl","launch",e.udid,n];await(0,cp_1.spawnSync)("xcrun",o,{},t),t.progress("Successfully launched the app on the simulator")}async buildProjectArchive(e,i,t){const{output:n,scheme:o,udid:s}=i,a=path_1.default.join(n,"./app"),{sourceDir:r}=e;fs_extra_1.default.ensureDirSync(path_1.default.dirname(a));const c=["archive",e.isWorkspace?"-workspace":"-project",e.name,"-scheme",o,"-archivePath",a];s&&c.push("-destination","id="+s);try{if(await(0,cp_1.spawnSync)("xcodebuild",c,{cwd:r},t),!fs_extra_1.default.existsSync(a+".xcarchive"))throw new Error(`Failed to build iOS project.\n ${a+".xcarchive"} does not found\n `);return t.progress(`Successfully archive the app: ${a}.xcarchive`),a+".xcarchive"}catch(i){throw new Error(`Failed to build iOS project. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}}async exportArchive(e,i,t,n){const o=path_1.default.join(t.output,"ipa");fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.emptyDirSync(o);const{exportOptionPlistPath:s}=t;if(!s)throw new Error("build ios ipa require exportOptionPlistPath in project.miniapp.json");let a="";a=path_1.default.isAbsolute(s)?s:path_1.default.join(t.projectPath,s);const r=["-exportArchive","-archivePath",i,"-exportOptionsPlist",a,"-exportPath",o];try{await(0,cp_1.spawnSync)("xcodebuild",r,{cwd:e.sourceDir},n)}catch(i){throw new Error(`To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}return fs_extra_1.default.removeSync(i),o}getTargetPaths(e){const i=JSON.parse(e);for(const e in i){if("app"===i[e].buildSettings.WRAPPER_EXTENSION)return{targetBuildDir:i[e].buildSettings.TARGET_BUILD_DIR,executableFolderPath:i[e].buildSettings.EXECUTABLE_FOLDER_PATH}}return{}}getBuildInfo(e,i,t){const n=this.getPlatformName(i),o=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",t,"-sdk",n,"-showBuildSettings","-json"].join(" "),s=child_process.execSync("xcodebuild "+o,{encoding:"utf8",cwd:e.sourceDir,env:(0,env_1.getProcessEnv)()}),a=this.getBuildProductDir(i),{executableFolderPath:r}=this.getTargetPaths(s);if(!r)throw new Error("Failed to get the app name.");return{sdk:n,appPath:`${a}/${r}`}}getPlatformName(e){const i=/export PLATFORM_NAME\\?="?(\w+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find PLATFORM_NAME in xcodebuild output.");return i[1]}getBuildProductDir(e){const i=/export BUILT_PRODUCTS_DIR\\?="?(.+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find BUILT_PRODUCTS_DIR in xcodebuild output.");return i[1]}xcbeautifyAvailable(){try{child_process.execSync("xcbeautify --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}xcprettyAvailable(){try{child_process.execSync("xcpretty --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}async buildPlugin(e,i){const{pluginId:t,projectPath:n,buildShellPath:o}=e;i.progress("start build native plugin...");try{const e=[n,t];fs_extra_1.default.chmodSync(o,"777"),buildIOSPluginTask[t]?(i.message("fail","存在未结束的插件构建任务,需等待构建结束..."),await buildIOSPluginTask[t].getResult(!0)):(buildIOSPluginTask[t]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,o,e,{},i)),await buildIOSPluginTask[t].getResult(!0),buildIOSPluginTask[t]=void 0)}catch(e){throw buildIOSPluginTask[t]=void 0,new Error("build plugin failed: "+e)}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let o="";Object.keys(t).forEach(e=>{var s,a,r,c;(null===(a=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===a?void 0:a[t[e]])&&(o+=`${e} = "${null===(c=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===c?void 0:c[t[e]]}";\n`)}),o&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),o))})}}exports.IOSUtils=IOSUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NativeCompiler=void 0;const define_1=require("../../config/define"),miniappJson_1=require("../../utils/miniappJson"),android_1=require("./android"),ios_1=require("./ios");class NativeCompiler{constructor(t){this.projectPath=t.projectInfo.projectPath,this.miniappDirPath=t.miniappDirPath,this.devtoolsVersion=t.devtoolsVersion}getHandler(t){let i=null;const e=(0,miniappJson_1.getMiniappJson)(this.projectPath,t);return t===define_1.PLATFORM["mini-android"]?i=new android_1.AndroidUtils(e.projectPath,e.project,this.miniappDirPath,this.devtoolsVersion):t===define_1.PLATFORM["mini-ios"]&&(i=new ios_1.IOSUtils(e.projectPath,e.project,this.miniappDirPath,this.devtoolsVersion)),i}validNativePlatform(t){return t===define_1.PLATFORM["mini-android"]||t===define_1.PLATFORM["mini-ios"]}async getAndroidDevices(){const t=this.getHandler(define_1.PLATFORM["mini-android"]);return await t.getDevices()}async getIOSDevices(){const t=this.getHandler(define_1.PLATFORM["mini-ios"]);return await t.getDevices()}async run(t,i){const{targetPlatform:e,opts:a}=t;if(!this.validNativePlatform(e))return;const r=(0,miniappJson_1.getMiniappJson)(this.projectPath,e),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NativeCompiler=void 0;const define_1=require("../../config/define"),miniappJson_1=require("../../utils/miniappJson"),android_1=require("./android"),ios_1=require("./ios");class NativeCompiler{constructor(t){this.projectPath=t.projectInfo.projectPath,this.miniappDirPath=t.miniappDirPath,this.devtoolsVersion=t.devtoolsVersion}getHandler(t){let i=null;const e=(0,miniappJson_1.getMiniappJson)(this.projectPath,t);return t===define_1.PLATFORM["mini-android"]?i=new android_1.AndroidUtils(e.projectPath,e.project,this.miniappDirPath,this.devtoolsVersion):t===define_1.PLATFORM["mini-ios"]&&(i=new ios_1.IOSUtils(e.projectPath,e.project,this.miniappDirPath,this.devtoolsVersion)),i}validNativePlatform(t){return t===define_1.PLATFORM["mini-android"]||t===define_1.PLATFORM["mini-ios"]}async getAndroidDevices(){const t=this.getHandler(define_1.PLATFORM["mini-android"]);return await t.getDevices()}async getIOSDevices(){const t=this.getHandler(define_1.PLATFORM["mini-ios"]);return await t.getDevices()}async run(t,i){const{targetPlatform:e,opts:a}=t;if(!this.validNativePlatform(e))return;const r=(0,miniappJson_1.getMiniappJson)(this.projectPath,e),s=this.getHandler(e);let n={};const{buildType:o="LOCAL"}=a;return"LOCAL"===o?(n=r.runArgs||{},await s.runLocal(Object.assign(Object.assign({projectPath:this.projectPath},n),a),i)):await s.runCloud(Object.assign({projectPath:this.projectPath},a),i)}async build(t,i){const{targetPlatform:e,opts:a={}}=t;if(!this.validNativePlatform(e))return;const r=this.getHandler(e),s=(0,miniappJson_1.getMiniappJson)(this.projectPath,e);let n={};const{buildType:o="LOCAL"}=a;return"LOCAL"===o?(n=s.buildArgs||{},await r.buildLocal(Object.assign(Object.assign({projectPath:this.projectPath},n),a),i)):await r.buildCloud(Object.assign({projectPath:this.projectPath},a),i)}async buildPlugin(t,i){const{targetPlatform:e,opts:a={}}=t;if(!this.validNativePlatform(e))return;const r=this.getHandler(e);return await r.buildPlugin(Object.assign({projectPath:this.projectPath},a),i)}async packIOSCloudBuildMaterial(t,i){const{targetPlatform:e,opts:a={}}=t;if(!this.validNativePlatform(e))return;const r=this.getHandler(e);return await r.packIOSCloudBuildMaterial(Object.assign({projectPath:this.projectPath},a),i)}async codesignIOSApp(t,i){const{targetPlatform:e,opts:a={}}=t;if(!this.validNativePlatform(e))return;const r=this.getHandler(e);return await r.codesignIOSApp(Object.assign({projectPath:this.projectPath},a),i)}}exports.NativeCompiler=NativeCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const entryProcess_1=require("../../utils/subprocess/entryProcess"),progressRecorder_1=require("../../utils/progressRecorder"),nativeCompiler_1=require("./nativeCompiler");let nativeCompiler;async function initHandler(e){const{projectInfo:
|
|
1
|
+
var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const entryProcess_1=require("../../utils/subprocess/entryProcess"),progressRecorder_1=require("../../utils/progressRecorder"),nativeCompiler_1=require("./nativeCompiler");let nativeCompiler;async function initHandler(e){const{projectInfo:i,passData:r}=e.data,{miniappDirPath:a,devtoolsVersion:s}=r;nativeCompiler=new nativeCompiler_1.NativeCompiler({projectInfo:i,miniappDirPath:a,devtoolsVersion:s})}async function messageHandler(e){if(e.type,"request"===e.type){const{id:i,name:r,data:a}=e,s=i,n=new progressRecorder_1.Recorder((e,i,r)=>{process.send({type:"progress",id:e,taskId:s,status:i,message:r})});a.fullEnv&&(global.fullEnv=a.fullEnv);try{let e;const t=`${r}-${s}`;if("buildNative"===r)e=await n.run(t,async()=>await nativeCompiler.build(a,n));else if("runNative"===r)e=await n.run(t,async()=>await nativeCompiler.run(a,n));else if("buildNativePlugin"===r)e=await n.run(t,async()=>await nativeCompiler.buildPlugin(a,n));else if("packIOSCloudBuildMaterial"===r)e=await n.run(t,async()=>await nativeCompiler.packIOSCloudBuildMaterial(a,n));else{if("codesignIOSApp"!==r)throw new Error("unknown command "+r);e=await n.run(t,async()=>await nativeCompiler.codesignIOSApp(a,n))}process.send({type:"response",id:i,data:e})}catch(e){process.send({type:"response",id:i,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}(0,entryProcess_1.runSubProcess)({initHandler:initHandler,messageHandler:messageHandler,timeout:(null===(_b=process.env)||void 0===_b?void 0:_b.timeout)||3e5});
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
SOURCEIPA="$1"
|
|
4
4
|
OUTPUT="$2"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
OUTPUTAPP="$3"
|
|
6
|
+
HASNES="$4"
|
|
7
|
+
UNIVERSALLINK="$5"
|
|
8
|
+
miniappCacheDir="$6"
|
|
9
|
+
CERTIFICATENAME="$7"
|
|
10
|
+
MOBILEPROV="$8"
|
|
11
|
+
extensionProfilePath="$9"
|
|
11
12
|
|
|
12
13
|
echo $UNIVERSALLINK
|
|
13
14
|
echo $miniappCacheDir
|
|
@@ -24,7 +25,7 @@ fi
|
|
|
24
25
|
if [ "$CERTIFICATENAME" != 'Cancel' ]; then
|
|
25
26
|
# 选择profile
|
|
26
27
|
if [ "$MOBILEPROV" == '' ]; then
|
|
27
|
-
MOBILEPROV=$(osascript -e 'set profilePath to choose file with prompt "
|
|
28
|
+
MOBILEPROV=$(osascript -e 'set profilePath to choose file with prompt "请选择类型的 profile 文件(mobileprovision文件)" of type {"mobileprovision"}' -e 'if profilePath is not equal to false then' -e 'set profilePath to POSIX path of profilePath' -e 'end if' 2>/dev/null)
|
|
28
29
|
fi
|
|
29
30
|
if [ "$MOBILEPROV" != '' ]; then
|
|
30
31
|
if [ "$HASNES" == 'true' ]; then
|
|
@@ -253,10 +254,17 @@ bundleShortVersionString=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersi
|
|
|
253
254
|
|
|
254
255
|
echo "Create the Signed IPA"
|
|
255
256
|
cd $temp_extracted
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
|
|
258
|
+
if [ "$OUTPUTAPP" == 'false' ]; then
|
|
259
|
+
zip -x "/*.cstemp" -qry ../extracted.ipa *
|
|
260
|
+
cd ..
|
|
261
|
+
bundleId=${bundleId//./}
|
|
262
|
+
mv extracted.ipa $OUTPUT/$bundleId-$bundleShortVersionString.ipa
|
|
263
|
+
else
|
|
264
|
+
cd ./Payload
|
|
265
|
+
rm -rf "$OUTPUT/demo.app"
|
|
266
|
+
cp -R "$APPLICATION" "$OUTPUT/$OUTPUTAPP"
|
|
267
|
+
fi
|
|
260
268
|
|
|
261
269
|
rm -rf $temp_dir
|
|
262
270
|
# rm sign_items.txt
|
package/dist/utils/codesign.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkXcodeEnv=exports.codesignAndExport=void 0;const generateIpa_1=require("./generateIpa"),singletontask_1=require("./singletontask"),cp_1=require("./cp"),path=require("path"),signAndInstallTask={};async function codesignAndExport(e,n,t,s,i,a,c){var r;const{output:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkXcodeEnv=exports.codesignAndExport=void 0;const generateIpa_1=require("./generateIpa"),singletontask_1=require("./singletontask"),cp_1=require("./cp"),path=require("path"),signAndInstallTask={};async function codesignAndExport(e,n,t,s,i,a,c,o){var r;const{output:p}=s,d=path.join(__dirname,"../static/scripts/resignIpa"),l=await(0,generateIpa_1.generateIpa)(n,i),g=(null===(r=s.entitlements)||void 0===r?void 0:r["com.apple.developer.associated-domains"])||"";try{await checkXcodeEnv(i);const e=[l,p,s.outputAppWithName?s.outputAppWithName:"false",a?"true":"",g,t];let n=!1;if(s.certificate?(e.push(s.certificate),s.profile?(e.push(s.profile),n=!0,s.tpnsProfile?(e.push(s.tpnsProfile),i.message("doing","certificate: find tpns profile")):i.message("doing","certificate: cant find tpns profile")):i.message("fail","certificate: cant find profile")):!0===o?n=!0:i.message("fail","certificate: cant find certificate"),!n)throw i.message("fail","codesignAndExport missing needed info"),new Error("Failed! codesignAndExport missing needed info");return signAndInstallTask[l]||(signAndInstallTask[l]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,d,e,{},i))),await signAndInstallTask[l].getResult(!0),{success:!0}}catch(e){return{success:!1,errMsg:e.message}}finally{delete signAndInstallTask[l]}}async function checkXcodeEnv(e){const n=path.join(__dirname,"../static/scripts/checkXcodeEnv");await(0,cp_1.spawnSyncExecShell)(n,[],{},e)}exports.codesignAndExport=codesignAndExport,exports.checkXcodeEnv=checkXcodeEnv;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateIpa=void 0;const zip_1=require("./zip"),path=require("path"),os=require("os"),fse=require("fs-extra");async function generateIpa(e,i){let r="";if(e.endsWith(".app")){const a=path.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateIpa=void 0;const zip_1=require("./zip"),path=require("path"),os=require("os"),fse=require("fs-extra");async function generateIpa(e,i){let r="";if(e.endsWith(".app")){const a=path.basename(e),p=os.tmpdir();r=path.join(p,"miniapp-unsigned.ipa");const t=path.join(p,"appdir"),n=path.join(t,"Payload");fse.existsSync(t)&&fse.removeSync(t),fse.ensureDirSync(n),fse.copySync(e,path.join(n,a)),null==i||i.progress("pack the ipa..."),fse.existsSync(r)&&fse.removeSync(r);try{await(0,zip_1.archiveZip)(t,r)}catch(e){throw new Error("generateIpa failed archiveZip file")}}else{if(!e.endsWith(".ipa"))throw new Error("invalid ipa/.app file");r=e}return r}exports.generateIpa=generateIpa;
|
package/dist/utils/log.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.error=exports.warn=exports.debug=exports.log=exports.info=exports.success=void 0;const tslib_1=require("tslib"),chalk_1=tslib_1.__importDefault(require("chalk"))
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.error=exports.warn=exports.debug=exports.log=exports.info=exports.success=void 0;const tslib_1=require("tslib"),chalk_1=tslib_1.__importDefault(require("chalk"));function stringifyArgs(...e){return e.map(e=>{if("object"!=typeof e)return e;try{return JSON.stringify(e)}catch(r){return e}})}const success=(...e)=>console.debug(chalk_1.default.green("[success]"),...stringifyArgs(...e));exports.success=success;const info=(...e)=>console.log(chalk_1.default.blue("[info]"),...stringifyArgs(...e));exports.info=info;const log=(...e)=>console.log(chalk_1.default.blue("[log]"),...stringifyArgs(...e));exports.log=log;const debug=(...e)=>console.debug(chalk_1.default.yellow("[debug]"),...stringifyArgs(...e));exports.debug=debug;const warn=(...e)=>console.log(chalk_1.default.yellow("[warn]"),...stringifyArgs(...e));exports.warn=warn;const error=(...e)=>console.log(chalk_1.default.red("[error]"),...stringifyArgs(...e));exports.error=error;
|
package/dist/utils/tools.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkIsUseCompilerPlugins=exports.isGameApp=exports.isLeftSubPathOfRight=exports.pathRelative=exports.compareVersion=exports.unifyPath=exports.getWorkersPath=exports.getPluginJson=exports.getAppJson=exports.getTerm=exports.checkIsIndependentSubpackage=exports.checkIsInSubPackage=exports.devtoolsError=exports.devtoolsLog=exports.devtoolsInfo=exports.formatTime=exports.formatNumber=exports.generateMD5=exports.formatSourceMap=exports.isFileIncluded=exports.isFileIgnored=exports.leading=exports.trailing=exports.escapeQuot=exports.mkdirSync=exports.rmSync=exports.isHexColor=exports.formatJSONParseErr=exports.bufferToUtf8String=exports.getType=exports.wrapCodeByEval=exports.escapeScript=exports.normalizePath=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")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame")),minimatch_1=tslib_1.__importDefault(require("minimatch")),startWith_1=tslib_1.__importDefault(require("licia/startWith")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),lodash_1=tslib_1.__importDefault(require("lodash")),define_1=require("../config/define"),types_1=require("../types"),jsonlint=require("./jsonlint");function normalizePath(e=""){const t=path_1.default.posix.normalize(e.replace(/\\/g,"/"));return!e.startsWith("//")&&!e.startsWith("\\\\")||t.startsWith("//")?t:"/"+t}function escapeScript(e){return e?e.replace(/<script/g,"<script").replace(/<\/script/g,"</script"):e}function wrapCodeByEval(e){return`;(window.eval || __global.__hackEval)('${e}')`}function getType(e){return Object.prototype.toString.call(e).toLowerCase().split(" ")[1].replace("]","")}exports.normalizePath=normalizePath,exports.escapeScript=escapeScript,exports.wrapCodeByEval=wrapCodeByEval,exports.getType=getType;const bufferToUtf8String=e=>{const t=e.toString();if(0===Buffer.compare(Buffer.from(t,"utf8"),e))return t};function getErrLine(e,t,r,o){r=r>0?r:1;return`${o}\n${(0,babel_code_frame_1.default)(e,t,r)}`}exports.bufferToUtf8String=bufferToUtf8String;const formatJSONParseErr=e=>{const t=e.data||"";try{jsonlint.parser.parse(t)}catch(r){try{const o=`Expecting ${r.expected}, got ${r.token}`,n=getErrLine(t,r.line,r.loc.first_column,o);return`${e.filePath}\n${n}`}catch(e){}}return`${e.filePath}\n${e.error}`};exports.formatJSONParseErr=formatJSONParseErr;const isHexColor=e=>/^#[a-f\d]{3}$/i.test(e)||/^#[a-f\d]{4}$/i.test(e)||/^#[a-f\d]{6}$/i.test(e)||/^#[a-f\d]{8}$/i.test(e);function rmSync(e){try{if(e=path_1.default.resolve(e),!fs_1.default.existsSync(e))return;if(fs_1.default.lstatSync(e).isDirectory()){const t=fs_1.default.readdirSync(e);if(t.length>0)for(let r=0,o=t.length;r<o;r++)rmSync(path_1.default.posix.join(e,t[r]));fs_1.default.rmdirSync(e)}else fs_1.default.unlinkSync(e)}catch(e){}}function mkdirSync(e){if(e=path_1.default.resolve(e),fs_1.default.existsSync(e)){if(fs_1.default.lstatSync(e).isDirectory())return;fs_1.default.unlinkSync(e)}mkdirSync(path_1.default.dirname(e)),fs_1.default.mkdirSync(e)}function escapeQuot(e,t="`"){return e?"`"===t?e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$"):'"'===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/"/g,'\\"'):"'"===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/'/g,"\\'"):e:e}function trailing(e,t,r=!1){return r?e.endsWith(t)?e.slice(0,e.length-1):e:e.endsWith(t)?e:e+t}function leading(e,t,r=!1){return r?e.startsWith(t)?e.slice(1):e:e.startsWith(t)?e:t+e}exports.isHexColor=isHexColor,exports.rmSync=rmSync,exports.mkdirSync=mkdirSync,exports.escapeQuot=escapeQuot,exports.trailing=trailing,exports.leading=leading;const FFSPRGRulesFactory=function(e){let t=null,r=Object.create(null);return function(e,o){if(o.length<1)return!1;if(t===o){if(void 0!==r[e])return r[e]}else t=o,r=Object.create(null);const n=e.replace(/\\/g,"/").toLowerCase();if(!n)return!1;const i=n.slice(n.lastIndexOf("/")+1);let s=!1;for(const e of o){if(!e)continue;const t=e.value.toLowerCase();if("prefix"===e.type)s=i.startsWith(t);else if("suffix"===e.type)s=i.endsWith(t);else if("folder"===e.type)s=leading(n,"/").startsWith(trailing(leading(t,"/"),"/"));else if("file"===e.type)s=leading(n,"/")===leading(t,"/");else if("glob"===e.type)try{s=(0,minimatch_1.default)(n,t)||(0,minimatch_1.default)(leading(n,"/"),t)}catch(e){s=!1}else if("regexp"===e.type)try{s=new RegExp(t,"igm").test(n)||new RegExp(t,"igm").test(leading(n,"/"))}catch(e){s=!1}if(s)break}return r[e]=s,s}};function formatSourceMap(e){if(e){if("string"===getType(e))return e;try{return JSON.stringify(e)}catch(e){}}}function generateMD5(e){const t=crypto_1.default.createHash("md5");return t.update(e),t.digest("hex")}exports.isFileIgnored=FFSPRGRulesFactory(),exports.isFileIncluded=FFSPRGRulesFactory(),exports.formatSourceMap=formatSourceMap,exports.generateMD5=generateMD5;const formatNumber=e=>e>9?""+e:"0"+e;exports.formatNumber=formatNumber;const formatTime=e=>{const t=e.getFullYear(),r=e.getMonth()+1,o=e.getDate(),n=e.getHours(),i=e.getMinutes(),s=e.getSeconds();return`${[t,r,o].map(exports.formatNumber).join("/")} ${[n,i,s].map(exports.formatNumber).join(":")}`};exports.formatTime=formatTime;const isDevtools=process.__nwjs&&window.nw&&"wechatwebdevtools"===nw.App.manifest.appname;function devtoolsInfo(...e){isDevtools&&console.info(...e)}function devtoolsLog(...e){isDevtools&&console.log(...e)}function devtoolsError(...e){isDevtools&&console.error(...e)}function getPluginByAliasOrProvider(e,t){if(e){const r=e[t];if(r)return{alias:t,provider:r.provider,version:r.version};for(const r in e){const o=e[r];if(o.provider===t)return{alias:r,provider:o.provider,version:o.version}}}}function checkPluginByAliasOrProvider(e,t){let r;if(e.subPackages)for(const o of e.subPackages)if(r=getPluginByAliasOrProvider(o.plugins,t),r)return Object.assign(Object.assign({},r),{config:o});if(r=getPluginByAliasOrProvider(e.plugins,t),r)return r}function checkIsInSubPackage(e,t=""){let r;if((0,startWith_1.default)(t,"plugin://")){const r=t.match(/^plugin:\/\/([^/]*)\/(.*)/),o=null==r?void 0:r[1];if(!o)return;const n=checkPluginByAliasOrProvider(e,o);return null==n?void 0:n.config}if(e.subPackages)for(let o=0,n=e.subPackages.length;o<n;o++){const n=e.subPackages[o];if(t.startsWith(n.root)){r=n;break}}return r}function checkIsIndependentSubpackage(e,t){const r=checkIsInSubPackage(e,t);if(r&&!0===r.independent)return r}function getTerm(){if(!!!(null===window||void 0===window?void 0:window.nw))return require("terminal-kit").terminal}function getTargetPlatformJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=Object.values(define_1.PLATFORM),o=fs_extra_1.default.readJsonSync(e),n=lodash_1.default.omit(o,r);return lodash_1.default.merge(n,o[t]||("mini-weixin"===t?o["mini-wechat"]:{}))}function getAppJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.miniprogramRoot||"","app.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found app.json");return getTargetPlatformJson(r,t)}function getPluginJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.pluginRoot||"","plugin.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found plugin.json");return getTargetPlatformJson(r,t)}exports.devtoolsInfo=devtoolsInfo,exports.devtoolsLog=devtoolsLog,exports.devtoolsError=devtoolsError,exports.checkIsInSubPackage=checkIsInSubPackage,exports.checkIsIndependentSubpackage=checkIsIndependentSubpackage,exports.getTerm=getTerm,exports.getAppJson=getAppJson,exports.getPluginJson=getPluginJson;const getWorkersPath=e=>"string"==typeof e?e:e.path;exports.getWorkersPath=getWorkersPath;const unifyPath=e=>e.replace(/\\/g,"/");exports.unifyPath=unifyPath;const compareVersion=(e,t)=>{e=e.split("."),t=t.split(".");const r=Math.max(e.length,t.length);for(;e.length<r;)e.push("0");for(;t.length<r;)t.push("0");for(let o=0;o<r;o++){const r=parseInt(e[o],10),n=parseInt(t[o],10);if(r>n)return 1;if(r<n)return-1}return 0};exports.compareVersion=compareVersion;const pathRelative=(e,t)=>(e=path_1.default.posix.normalize(e.replace(/\\/g,"/")),t=path_1.default.posix.normalize(t.replace(/\\/g,"/")),path_1.default.posix.relative(e,t));function _isLeftSubPathOfRight(e,t){if(!t)return!0;if(t=normalizePath(t),e=normalizePath(e),!t.endsWith("/")){if(e===t)return!0;t+="/"}return!!e.startsWith(t)}function isLeftSubPathOfRight(e,t){void 0===e&&(console.error(new Error("The child string is undefined here, please check!!")),e="");const r=e.startsWith(t),o=_isLeftSubPathOfRight(e,t);return r!==o&&console.error(new Error(`${e} ${t} difference check sub path here! new result: ${o}`)),o}function isGameApp(e){return e.type===types_1.EProjectType.miniGame||e.type===types_1.EProjectType.miniGamePlugin}exports.pathRelative=pathRelative,exports.isLeftSubPathOfRight=isLeftSubPathOfRight,exports.isGameApp=isGameApp;const checkIsUseCompilerPlugins=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkIsUseCompilerPlugins=exports.isGameApp=exports.isLeftSubPathOfRight=exports.pathRelative=exports.compareVersion=exports.unifyPath=exports.getWorkersPath=exports.getPluginJson=exports.getAppJson=exports.getTerm=exports.checkIsIndependentSubpackage=exports.checkIsInSubPackage=exports.devtoolsError=exports.devtoolsLog=exports.devtoolsInfo=exports.formatTime=exports.formatNumber=exports.generateMD5=exports.formatSourceMap=exports.isFileIncluded=exports.isFileIgnored=exports.leading=exports.trailing=exports.escapeQuot=exports.mkdirSync=exports.rmSync=exports.isHexColor=exports.formatJSONParseErr=exports.bufferToUtf8String=exports.getType=exports.wrapCodeByEval=exports.escapeScript=exports.normalizePath=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")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame")),minimatch_1=tslib_1.__importDefault(require("minimatch")),startWith_1=tslib_1.__importDefault(require("licia/startWith")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),lodash_1=tslib_1.__importDefault(require("lodash")),define_1=require("../config/define"),types_1=require("../types"),jsonlint=require("./jsonlint");function normalizePath(e=""){const t=path_1.default.posix.normalize(e.replace(/\\/g,"/"));return!e.startsWith("//")&&!e.startsWith("\\\\")||t.startsWith("//")?t:"/"+t}function escapeScript(e){return e?e.replace(/<script/g,"<script").replace(/<\/script/g,"</script"):e}function wrapCodeByEval(e){return`;(window.eval || __global.__hackEval)('${e}')`}function getType(e){return Object.prototype.toString.call(e).toLowerCase().split(" ")[1].replace("]","")}exports.normalizePath=normalizePath,exports.escapeScript=escapeScript,exports.wrapCodeByEval=wrapCodeByEval,exports.getType=getType;const bufferToUtf8String=e=>{const t=e.toString();if(0===Buffer.compare(Buffer.from(t,"utf8"),e))return t};function getErrLine(e,t,r,o){r=r>0?r:1;return`${o}\n${(0,babel_code_frame_1.default)(e,t,r)}`}exports.bufferToUtf8String=bufferToUtf8String;const formatJSONParseErr=e=>{const t=e.data||"";try{jsonlint.parser.parse(t)}catch(r){try{const o=`Expecting ${r.expected}, got ${r.token}`,n=getErrLine(t,r.line,r.loc.first_column,o);return`${e.filePath}\n${n}`}catch(e){}}return`${e.filePath}\n${e.error}`};exports.formatJSONParseErr=formatJSONParseErr;const isHexColor=e=>/^#[a-f\d]{3}$/i.test(e)||/^#[a-f\d]{4}$/i.test(e)||/^#[a-f\d]{6}$/i.test(e)||/^#[a-f\d]{8}$/i.test(e);function rmSync(e){try{if(e=path_1.default.resolve(e),!fs_1.default.existsSync(e))return;if(fs_1.default.lstatSync(e).isDirectory()){const t=fs_1.default.readdirSync(e);if(t.length>0)for(let r=0,o=t.length;r<o;r++)rmSync(path_1.default.posix.join(e,t[r]));fs_1.default.rmdirSync(e)}else fs_1.default.unlinkSync(e)}catch(e){}}function mkdirSync(e){if(e=path_1.default.resolve(e),fs_1.default.existsSync(e)){if(fs_1.default.lstatSync(e).isDirectory())return;fs_1.default.unlinkSync(e)}mkdirSync(path_1.default.dirname(e)),fs_1.default.mkdirSync(e)}function escapeQuot(e,t="`"){return e?"`"===t?e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$"):'"'===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/"/g,'\\"'):"'"===t?e.replace(/\\/g,"\\\\").replace(/\r\n/g,"\n").replace(/\n/g,"\\n").replace(/'/g,"\\'"):e:e}function trailing(e,t,r=!1){return r?e.endsWith(t)?e.slice(0,e.length-1):e:e.endsWith(t)?e:e+t}function leading(e,t,r=!1){return r?e.startsWith(t)?e.slice(1):e:e.startsWith(t)?e:t+e}exports.isHexColor=isHexColor,exports.rmSync=rmSync,exports.mkdirSync=mkdirSync,exports.escapeQuot=escapeQuot,exports.trailing=trailing,exports.leading=leading;const FFSPRGRulesFactory=function(e){let t=null,r=Object.create(null);return function(e,o){if(o.length<1)return!1;if(t===o){if(void 0!==r[e])return r[e]}else t=o,r=Object.create(null);const n=e.replace(/\\/g,"/").toLowerCase();if(!n)return!1;const i=n.slice(n.lastIndexOf("/")+1);let s=!1;for(const e of o){if(!e)continue;const t=e.value.toLowerCase();if("prefix"===e.type)s=i.startsWith(t);else if("suffix"===e.type)s=i.endsWith(t);else if("folder"===e.type)s=leading(n,"/").startsWith(trailing(leading(t,"/"),"/"));else if("file"===e.type)s=leading(n,"/")===leading(t,"/");else if("glob"===e.type)try{s=(0,minimatch_1.default)(n,t)||(0,minimatch_1.default)(leading(n,"/"),t)}catch(e){s=!1}else if("regexp"===e.type)try{s=new RegExp(t,"igm").test(n)||new RegExp(t,"igm").test(leading(n,"/"))}catch(e){s=!1}if(s)break}return r[e]=s,s}};function formatSourceMap(e){if(e){if("string"===getType(e))return e;try{return JSON.stringify(e)}catch(e){}}}function generateMD5(e){const t=crypto_1.default.createHash("md5");return t.update(e),t.digest("hex")}exports.isFileIgnored=FFSPRGRulesFactory(),exports.isFileIncluded=FFSPRGRulesFactory(),exports.formatSourceMap=formatSourceMap,exports.generateMD5=generateMD5;const formatNumber=e=>e>9?""+e:"0"+e;exports.formatNumber=formatNumber;const formatTime=e=>{const t=e.getFullYear(),r=e.getMonth()+1,o=e.getDate(),n=e.getHours(),i=e.getMinutes(),s=e.getSeconds();return`${[t,r,o].map(exports.formatNumber).join("/")} ${[n,i,s].map(exports.formatNumber).join(":")}`};exports.formatTime=formatTime;const isDevtools=process.__nwjs&&window.nw&&"wechatwebdevtools"===nw.App.manifest.appname;function devtoolsInfo(...e){isDevtools&&console.info(...e)}function devtoolsLog(...e){isDevtools&&console.log(...e)}function devtoolsError(...e){isDevtools&&console.error(...e)}function getPluginByAliasOrProvider(e,t){if(e){const r=e[t];if(r)return{alias:t,provider:r.provider,version:r.version};for(const r in e){const o=e[r];if(o.provider===t)return{alias:r,provider:o.provider,version:o.version}}}}function checkPluginByAliasOrProvider(e,t){let r;if(e.subPackages)for(const o of e.subPackages)if(r=getPluginByAliasOrProvider(o.plugins,t),r)return Object.assign(Object.assign({},r),{config:o});if(r=getPluginByAliasOrProvider(e.plugins,t),r)return r}function checkIsInSubPackage(e,t=""){let r;if((0,startWith_1.default)(t,"plugin://")){const r=t.match(/^plugin:\/\/([^/]*)\/(.*)/),o=null==r?void 0:r[1];if(!o)return;const n=checkPluginByAliasOrProvider(e,o);return null==n?void 0:n.config}if(e.subPackages)for(let o=0,n=e.subPackages.length;o<n;o++){const n=e.subPackages[o];if(t.startsWith(n.root)){r=n;break}}return r}function checkIsIndependentSubpackage(e,t){const r=checkIsInSubPackage(e,t);if(r&&!0===r.independent)return r}function getTerm(){if(!!!(null===window||void 0===window?void 0:window.nw))return require("terminal-kit").terminal}function getTargetPlatformJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=Object.values(define_1.PLATFORM),o=fs_extra_1.default.readJsonSync(e),n=lodash_1.default.omit(o,r);return lodash_1.default.merge(n,o[t]||("mini-weixin"===t?o["mini-wechat"]:{}))}function getAppJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.miniprogramRoot||"","app.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found app.json");return getTargetPlatformJson(r,t)}function getPluginJson(e,t=define_1.PLATFORM["mini-weixin"]){const r=path_1.default.join(e.projectPath,e.pluginRoot||"","plugin.json");if(!fs_extra_1.default.existsSync(r))throw Error("no found plugin.json");return getTargetPlatformJson(r,t)}exports.devtoolsInfo=devtoolsInfo,exports.devtoolsLog=devtoolsLog,exports.devtoolsError=devtoolsError,exports.checkIsInSubPackage=checkIsInSubPackage,exports.checkIsIndependentSubpackage=checkIsIndependentSubpackage,exports.getTerm=getTerm,exports.getAppJson=getAppJson,exports.getPluginJson=getPluginJson;const getWorkersPath=e=>"string"==typeof e?e:e.path;exports.getWorkersPath=getWorkersPath;const unifyPath=e=>e.replace(/\\/g,"/");exports.unifyPath=unifyPath;const compareVersion=(e,t)=>{e=e.split("."),t=t.split(".");const r=Math.max(e.length,t.length);for(;e.length<r;)e.push("0");for(;t.length<r;)t.push("0");for(let o=0;o<r;o++){const r=parseInt(e[o],10),n=parseInt(t[o],10);if(r>n)return 1;if(r<n)return-1}return 0};exports.compareVersion=compareVersion;const pathRelative=(e,t)=>(e=path_1.default.posix.normalize(e.replace(/\\/g,"/")),t=path_1.default.posix.normalize(t.replace(/\\/g,"/")),path_1.default.posix.relative(e,t));function _isLeftSubPathOfRight(e,t){if(!t)return!0;if(t=normalizePath(t),e=normalizePath(e),!t.endsWith("/")){if(e===t)return!0;t+="/"}return!!e.startsWith(t)}function isLeftSubPathOfRight(e,t){void 0===e&&(console.error(new Error("The child string is undefined here, please check!!")),e="");const r=e.startsWith(t),o=_isLeftSubPathOfRight(e,t);return r!==o&&console.error(new Error(`${e} ${t} difference check sub path here! new result: ${o}`)),o}function isGameApp(e){return e.type===types_1.EProjectType.miniGame||e.type===types_1.EProjectType.miniGamePlugin}exports.pathRelative=pathRelative,exports.isLeftSubPathOfRight=isLeftSubPathOfRight,exports.isGameApp=isGameApp;const checkIsUseCompilerPlugins=()=>!0;exports.checkIsUseCompilerPlugins=checkIsUseCompilerPlugins;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miniprogram-ci",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Module that build miniprogram project for web or app extracted from WeChatDevtools.",
|
|
5
5
|
"homepage": "https://developers.weixin.qq.com/community/homepage",
|
|
6
6
|
"main": "dist/index.js",
|