@gmcb/cli 0.5.4 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +37 -1
- package/lib/actions/build.js +181 -45
- package/lib/actions/copy.js +2 -2
- package/lib/actions/create.js +2 -3
- package/lib/actions/publish.js +67 -38
- package/lib/actions/skill.js +2 -3
- package/lib/apis/http.d.ts +49 -0
- package/lib/apis/http.js +133 -0
- package/lib/apis/index.d.ts +116 -0
- package/lib/apis/index.js +234 -0
- package/lib/bin.js +3 -1
- package/lib/commands/option.d.ts +2 -0
- package/lib/commands/option.js +2 -1
- package/lib/commands/platform.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/scripts/app-apk.d.ts +1 -0
- package/lib/scripts/app-apk.js +15 -0
- package/lib/scripts/app-wgt.d.ts +1 -0
- package/lib/scripts/app-wgt.js +15 -0
- package/lib/scripts/asar-zip.d.ts +1 -0
- package/lib/scripts/asar-zip.js +17 -0
- package/lib/scripts/h5-exe.d.ts +1 -0
- package/lib/scripts/h5-exe.js +17 -0
- package/lib/scripts/h5-zip.d.ts +1 -0
- package/lib/scripts/h5-zip.js +15 -0
- package/lib/scripts/mp-weixin.d.ts +1 -0
- package/lib/scripts/mp-weixin.js +37 -0
- package/lib/scripts/publish.d.ts +9 -0
- package/lib/scripts/publish.js +112 -0
- package/lib/scripts/wgt-zip.d.ts +1 -0
- package/lib/scripts/wgt-zip.js +15 -0
- package/lib/{actions → utils}/config.d.ts +24 -6
- package/lib/{actions → utils}/config.js +19 -17
- package/lib/utils/const.d.ts +25 -1
- package/lib/utils/const.js +31 -2
- package/lib/utils/function.d.ts +2 -0
- package/lib/utils/function.js +20 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/png2ico.d.ts +1 -0
- package/lib/utils/png2ico.js +48 -0
- package/package.json +8 -3
- package/schema.json +39 -3
package/lib/apis/http.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.http = void 0;
|
|
4
|
+
exports.setToken = setToken;
|
|
5
|
+
const const_1 = require("../utils/const");
|
|
6
|
+
class Http {
|
|
7
|
+
_header = {
|
|
8
|
+
'Tenant-Id': 1,
|
|
9
|
+
channel: 4,
|
|
10
|
+
};
|
|
11
|
+
get options() {
|
|
12
|
+
return {
|
|
13
|
+
baseUrl: const_1.BASE_URL[process.env.BUILD_ENV || ''] || '',
|
|
14
|
+
header: this._header,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 发送请求
|
|
19
|
+
*/
|
|
20
|
+
async request(config) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const { url = '', method, header, config: conf, params, ...rest } = config || {};
|
|
23
|
+
const { baseUrl = '', header: h } = this.options;
|
|
24
|
+
let mergeUrl = url;
|
|
25
|
+
if (!/^([\w]+?:)?\/\//i.test(url)) {
|
|
26
|
+
mergeUrl = `${baseUrl.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}`;
|
|
27
|
+
}
|
|
28
|
+
const headers = {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
...h,
|
|
31
|
+
...header,
|
|
32
|
+
...conf?.header,
|
|
33
|
+
};
|
|
34
|
+
if (params) {
|
|
35
|
+
let search = Object.keys(params)
|
|
36
|
+
.map((key) => `${key}=${params[key] || ''}`)
|
|
37
|
+
.join('&');
|
|
38
|
+
if (search) {
|
|
39
|
+
search = `${mergeUrl.indexOf('?') !== -1 ? '&' : '?'}${search}`;
|
|
40
|
+
}
|
|
41
|
+
mergeUrl = `${mergeUrl}${search}`;
|
|
42
|
+
}
|
|
43
|
+
const options = {
|
|
44
|
+
method,
|
|
45
|
+
mode: 'cors',
|
|
46
|
+
cache: 'no-cache',
|
|
47
|
+
headers,
|
|
48
|
+
...rest,
|
|
49
|
+
...conf,
|
|
50
|
+
};
|
|
51
|
+
if (options.data && typeof options.data !== 'string') {
|
|
52
|
+
if (options.data instanceof FormData) {
|
|
53
|
+
options['body'] = options.data;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
options['body'] = JSON.stringify(options.data);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
fetch(mergeUrl, options)
|
|
60
|
+
.then((e) => {
|
|
61
|
+
e.json()
|
|
62
|
+
.then((data) => {
|
|
63
|
+
if (data.code === 0) {
|
|
64
|
+
resolve(data);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
reject(data);
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
.catch((data) => {
|
|
71
|
+
reject(data);
|
|
72
|
+
});
|
|
73
|
+
})
|
|
74
|
+
.catch((e) => {
|
|
75
|
+
reject(e);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 发送POST请求
|
|
81
|
+
*/
|
|
82
|
+
async post(url, data = {}, config) {
|
|
83
|
+
return this.request({
|
|
84
|
+
url,
|
|
85
|
+
method: 'POST',
|
|
86
|
+
data,
|
|
87
|
+
config,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 发送DELETE请求
|
|
92
|
+
*/
|
|
93
|
+
async delete(url, params = {}, config) {
|
|
94
|
+
return this.request({
|
|
95
|
+
url,
|
|
96
|
+
method: 'DELETE',
|
|
97
|
+
params,
|
|
98
|
+
config,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 发送PUT请求
|
|
103
|
+
*/
|
|
104
|
+
async put(url, data = {}, config) {
|
|
105
|
+
return this.request({
|
|
106
|
+
url,
|
|
107
|
+
method: 'PUT',
|
|
108
|
+
data,
|
|
109
|
+
config,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 发送GET请求
|
|
114
|
+
*/
|
|
115
|
+
async get(url, params = {}, config) {
|
|
116
|
+
return this.request({
|
|
117
|
+
url,
|
|
118
|
+
method: 'GET',
|
|
119
|
+
params,
|
|
120
|
+
config,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function setToken(token) {
|
|
125
|
+
const header = exports.http.options.header;
|
|
126
|
+
if (token) {
|
|
127
|
+
header['Authorization'] = `Bearer ${token}`;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
delete header['Authorization'];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.http = new Http();
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 登录
|
|
3
|
+
*/
|
|
4
|
+
export declare function login(data: any): Promise<{
|
|
5
|
+
code?: number;
|
|
6
|
+
data?: any;
|
|
7
|
+
msg?: string;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* 获取品牌列表
|
|
11
|
+
*/
|
|
12
|
+
export declare function getBrandList(): Promise<{
|
|
13
|
+
code?: number;
|
|
14
|
+
data?: any;
|
|
15
|
+
msg?: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* 获取应用列表
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAppList(): Promise<{
|
|
21
|
+
code?: number;
|
|
22
|
+
data?: any;
|
|
23
|
+
msg?: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取最新版本
|
|
27
|
+
*/
|
|
28
|
+
export declare function getLastVersion(data: any): Promise<{
|
|
29
|
+
code?: number;
|
|
30
|
+
data?: any;
|
|
31
|
+
msg?: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* 保存版本
|
|
35
|
+
*/
|
|
36
|
+
export declare function saveVersion(data: any): Promise<{
|
|
37
|
+
code?: number;
|
|
38
|
+
data?: any;
|
|
39
|
+
msg?: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* 创建版本
|
|
43
|
+
*/
|
|
44
|
+
export declare function createVersion(data: any): Promise<{
|
|
45
|
+
code?: number;
|
|
46
|
+
data?: any;
|
|
47
|
+
msg?: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* 提交版本
|
|
51
|
+
*/
|
|
52
|
+
export declare function postVersion(data: any): Promise<{
|
|
53
|
+
code?: number;
|
|
54
|
+
data?: any;
|
|
55
|
+
msg?: string;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* 查询版本分页列表
|
|
59
|
+
*/
|
|
60
|
+
export declare function getVersionPage(params: {
|
|
61
|
+
appId: string;
|
|
62
|
+
publishType: number;
|
|
63
|
+
pageNo?: number;
|
|
64
|
+
pageSize?: number;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
code?: number;
|
|
67
|
+
data?: any;
|
|
68
|
+
msg?: string;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* 获取应用详情
|
|
72
|
+
*/
|
|
73
|
+
export declare function getAppDetail(id: string): Promise<{
|
|
74
|
+
code?: number;
|
|
75
|
+
data?: any;
|
|
76
|
+
msg?: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* 查询版本历史
|
|
80
|
+
*/
|
|
81
|
+
export declare function getVersionHistory(params: Record<string, any>): Promise<{
|
|
82
|
+
code?: number;
|
|
83
|
+
data?: any;
|
|
84
|
+
msg?: string;
|
|
85
|
+
}>;
|
|
86
|
+
export interface VersionParams {
|
|
87
|
+
brand?: string;
|
|
88
|
+
brandId?: number | string;
|
|
89
|
+
brandName?: string;
|
|
90
|
+
appId?: string;
|
|
91
|
+
username?: string;
|
|
92
|
+
password?: string;
|
|
93
|
+
type?: number;
|
|
94
|
+
status?: number;
|
|
95
|
+
platform?: string | number;
|
|
96
|
+
path?: string;
|
|
97
|
+
remoteUrl?: string | string[];
|
|
98
|
+
versionName?: string;
|
|
99
|
+
versionCode?: string | number;
|
|
100
|
+
channel?: string | number;
|
|
101
|
+
updateType?: number | string;
|
|
102
|
+
versionDesc?: string;
|
|
103
|
+
publishType?: number | string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 上传新版本
|
|
107
|
+
*/
|
|
108
|
+
export declare function uploadVersion(params: VersionParams): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* 发布版本
|
|
111
|
+
*/
|
|
112
|
+
export declare function publishVersion(params: VersionParams): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* 获取远程版本信息(自动登录)
|
|
115
|
+
*/
|
|
116
|
+
export declare function fetchRemoteVersionInfo(appId: string): Promise<any>;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.login = login;
|
|
4
|
+
exports.getBrandList = getBrandList;
|
|
5
|
+
exports.getAppList = getAppList;
|
|
6
|
+
exports.getLastVersion = getLastVersion;
|
|
7
|
+
exports.saveVersion = saveVersion;
|
|
8
|
+
exports.createVersion = createVersion;
|
|
9
|
+
exports.postVersion = postVersion;
|
|
10
|
+
exports.getVersionPage = getVersionPage;
|
|
11
|
+
exports.getAppDetail = getAppDetail;
|
|
12
|
+
exports.getVersionHistory = getVersionHistory;
|
|
13
|
+
exports.uploadVersion = uploadVersion;
|
|
14
|
+
exports.publishVersion = publishVersion;
|
|
15
|
+
exports.fetchRemoteVersionInfo = fetchRemoteVersionInfo;
|
|
16
|
+
const http_1 = require("./http");
|
|
17
|
+
const const_1 = require("../utils/const");
|
|
18
|
+
const config_1 = require("../utils/config");
|
|
19
|
+
/**
|
|
20
|
+
* 登录
|
|
21
|
+
*/
|
|
22
|
+
function login(data) {
|
|
23
|
+
return http_1.http.post('/admin-api/system/auth/login', data);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 获取品牌列表
|
|
27
|
+
*/
|
|
28
|
+
function getBrandList() {
|
|
29
|
+
return http_1.http.post('/admin-api/robot/brandManagement/list');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 获取应用列表
|
|
33
|
+
*/
|
|
34
|
+
function getAppList() {
|
|
35
|
+
return http_1.http.get('/admin-api/system/app-mofang/app/list');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取最新版本
|
|
39
|
+
*/
|
|
40
|
+
function getLastVersion(data) {
|
|
41
|
+
return http_1.http.post('/app-api/system/app/version/get-last-version', data);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 保存版本
|
|
45
|
+
*/
|
|
46
|
+
function saveVersion(data) {
|
|
47
|
+
return http_1.http.post('/admin-api/system/app/version/save', data);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 创建版本
|
|
51
|
+
*/
|
|
52
|
+
function createVersion(data) {
|
|
53
|
+
return http_1.http.post('/admin-api/system/app-mofang/version/create', data);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 提交版本
|
|
57
|
+
*/
|
|
58
|
+
function postVersion(data) {
|
|
59
|
+
return http_1.http.put('/admin-api/system/app-mofang/version/manual-publish', data);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 查询版本分页列表
|
|
63
|
+
*/
|
|
64
|
+
function getVersionPage(params) {
|
|
65
|
+
return http_1.http.get('/admin-api/system/app-mofang/version/page', params);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 获取应用详情
|
|
69
|
+
*/
|
|
70
|
+
function getAppDetail(id) {
|
|
71
|
+
return http_1.http.get('/admin-api/system/app-mofang/app/get', { id });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 查询版本历史
|
|
75
|
+
*/
|
|
76
|
+
function getVersionHistory(params) {
|
|
77
|
+
return http_1.http.get('/admin-api/system/app-mofang/version/history', params);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 上传新版本
|
|
81
|
+
*/
|
|
82
|
+
async function uploadVersion(params) {
|
|
83
|
+
const { brand, username, password, type, status, platform, path, remoteUrl, versionName, versionCode, } = params;
|
|
84
|
+
let brandId = '';
|
|
85
|
+
const { data: { accessToken }, } = await login({ username, password });
|
|
86
|
+
(0, http_1.setToken)(accessToken);
|
|
87
|
+
const { data: brandList } = await getBrandList();
|
|
88
|
+
const brandItem = brandList?.find(({ name, id }) => name === brand && Number(id) > 10000);
|
|
89
|
+
brandId = brandItem?.id;
|
|
90
|
+
const packageName = path?.split('/').filter(Boolean).pop();
|
|
91
|
+
const { data: latest } = await getLastVersion({ type, platform, packageName, version: 0 });
|
|
92
|
+
await saveVersion({
|
|
93
|
+
type,
|
|
94
|
+
status: status || 4,
|
|
95
|
+
platform,
|
|
96
|
+
brandId,
|
|
97
|
+
fileUrl: latest?.fileUrl || 'none',
|
|
98
|
+
hotUpdateUrl: remoteUrl,
|
|
99
|
+
name: versionName,
|
|
100
|
+
version: versionCode,
|
|
101
|
+
packageName,
|
|
102
|
+
comment: '修复一些已知问题',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 发布版本
|
|
107
|
+
*/
|
|
108
|
+
async function publishVersion(params) {
|
|
109
|
+
const { brandName, brandId, appId, username, password, remoteUrl, versionName, versionCode, channel, versionDesc, platform, ...rest } = params;
|
|
110
|
+
const publishType = Number(rest.publishType) || 3;
|
|
111
|
+
const updateType = Number(rest.updateType) || 2;
|
|
112
|
+
const { data: { accessToken }, } = await login({ username, password });
|
|
113
|
+
(0, http_1.setToken)(accessToken);
|
|
114
|
+
const { data: pageData } = await getVersionPage({ appId, publishType, pageNo: 1, pageSize: 10 });
|
|
115
|
+
const pageList = pageData?.list?.filter((item) => {
|
|
116
|
+
if (publishType == 1) {
|
|
117
|
+
return item.platformType === const_1.PLATFORM_TYPE[platform];
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}) || [];
|
|
121
|
+
const existingVersion = pageList.find((item) => String(item.versionNum) === String(versionCode));
|
|
122
|
+
let latest;
|
|
123
|
+
const firstPage = pageList[0];
|
|
124
|
+
if (firstPage) {
|
|
125
|
+
let historyParams;
|
|
126
|
+
if (firstPage.publishType == 1) {
|
|
127
|
+
historyParams = {
|
|
128
|
+
publishType: firstPage.publishType,
|
|
129
|
+
appName: firstPage.appName,
|
|
130
|
+
channelType: firstPage.channelType,
|
|
131
|
+
platformType: firstPage.platformType,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
historyParams = {
|
|
136
|
+
publishType,
|
|
137
|
+
appMofangId: firstPage.appMofangId,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const { data: historyData } = await getVersionHistory({ ...historyParams, pageNo: 1, pageSize: 1 });
|
|
141
|
+
latest = (Array.isArray(historyData) ? historyData : historyData?.list)?.[0];
|
|
142
|
+
}
|
|
143
|
+
if (!existingVersion && latest && Number(versionCode) <= Number(latest.versionNum)) {
|
|
144
|
+
throw new Error(`版本号不能小于上次发布 ${latest.versionNum}`);
|
|
145
|
+
}
|
|
146
|
+
let versionId;
|
|
147
|
+
if (existingVersion) {
|
|
148
|
+
versionId = existingVersion.id;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
let createData;
|
|
152
|
+
if (publishType == 1) {
|
|
153
|
+
const { data: brandList } = await getBrandList();
|
|
154
|
+
const brandItem = brandList?.find(({ name, id }) => {
|
|
155
|
+
if (Number(id) > 10000) {
|
|
156
|
+
if (brandId && id === brandId) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (brandName && name === brandName) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
});
|
|
165
|
+
createData = {
|
|
166
|
+
brandId: brandItem?.id,
|
|
167
|
+
appName: brandItem?.name,
|
|
168
|
+
channelType: const_1.CHANNEL_TYPE[channel],
|
|
169
|
+
platformType: const_1.PLATFORM_TYPE[platform],
|
|
170
|
+
updateType,
|
|
171
|
+
versionName,
|
|
172
|
+
versionNum: versionCode,
|
|
173
|
+
versionDesc: versionDesc || '修复一些已知问题',
|
|
174
|
+
fullPackageUrl: '',
|
|
175
|
+
fullPackageFileName: '',
|
|
176
|
+
resourcePackageUrl: '',
|
|
177
|
+
resourcePackageFileName: '',
|
|
178
|
+
publishType,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const { data: appList } = await getAppList();
|
|
183
|
+
const appItem = appList?.find((item) => item.appId === appId);
|
|
184
|
+
createData = {
|
|
185
|
+
appMofangId: appItem?.id,
|
|
186
|
+
appId,
|
|
187
|
+
appName: appItem?.name,
|
|
188
|
+
updateType,
|
|
189
|
+
versionName,
|
|
190
|
+
versionNum: versionCode,
|
|
191
|
+
versionDesc: versionDesc || '修复一些已知问题',
|
|
192
|
+
resourcePackageUrl: '',
|
|
193
|
+
resourcePackageFileName: '',
|
|
194
|
+
publishType,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const { data: newId } = await createVersion(createData);
|
|
198
|
+
versionId = newId;
|
|
199
|
+
}
|
|
200
|
+
const urls = Array.isArray(remoteUrl) ? remoteUrl : [remoteUrl || ''];
|
|
201
|
+
const fullUrl = urls.find((u) => !/\.zip$/i.test(u)) || '';
|
|
202
|
+
const resUrl = urls.find((u) => /\.zip$/i.test(u)) || '';
|
|
203
|
+
const fallbackFullUrl = existingVersion?.fullPackageUrl || latest?.fullPackageUrl || '';
|
|
204
|
+
const fallbackResUrl = existingVersion?.resourcePackageUrl || latest?.resourcePackageUrl || '';
|
|
205
|
+
await postVersion({
|
|
206
|
+
id: versionId,
|
|
207
|
+
fullPackageUrl: fullUrl || fallbackFullUrl,
|
|
208
|
+
resourcePackageUrl: resUrl || fallbackResUrl,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* 获取远程版本信息(自动登录)
|
|
213
|
+
*/
|
|
214
|
+
async function fetchRemoteVersionInfo(appId) {
|
|
215
|
+
const web = config_1.CONFIG_DATA.web;
|
|
216
|
+
const creds = (web?.[process.env.BUILD_ENV || ''] || web || {});
|
|
217
|
+
const { data: { accessToken }, } = await login({ username: creds.username, password: creds.password });
|
|
218
|
+
(0, http_1.setToken)(accessToken);
|
|
219
|
+
const { data: pageData } = await getVersionPage({ appId, publishType: 2, pageNo: 1, pageSize: 10 });
|
|
220
|
+
const version = pageData?.list?.[0];
|
|
221
|
+
if (!version)
|
|
222
|
+
throw new Error(`未查询到 ${appId} 应用数据`);
|
|
223
|
+
const { data: appDetail } = await getAppDetail(version.appMofangId);
|
|
224
|
+
let configJson = {};
|
|
225
|
+
try {
|
|
226
|
+
configJson = JSON.parse(appDetail?.configJson || '{}');
|
|
227
|
+
}
|
|
228
|
+
catch { }
|
|
229
|
+
return {
|
|
230
|
+
...version,
|
|
231
|
+
iconUrl: appDetail?.iconUrl,
|
|
232
|
+
configJson,
|
|
233
|
+
};
|
|
234
|
+
}
|
package/lib/bin.js
CHANGED
|
@@ -10,7 +10,7 @@ const create_1 = __importDefault(require("./actions/create"));
|
|
|
10
10
|
const dev_1 = __importDefault(require("./actions/dev"));
|
|
11
11
|
const build_1 = __importDefault(require("./actions/build"));
|
|
12
12
|
const publish_1 = __importDefault(require("./actions/publish"));
|
|
13
|
-
const config_1 = __importDefault(require("./
|
|
13
|
+
const config_1 = __importDefault(require("./utils/config"));
|
|
14
14
|
const copy_1 = __importDefault(require("./actions/copy"));
|
|
15
15
|
const skill_1 = require("./actions/skill");
|
|
16
16
|
const commands_1 = require("./commands");
|
|
@@ -49,6 +49,7 @@ program
|
|
|
49
49
|
.option(...commands_1.win)
|
|
50
50
|
.option(...commands_1.mac)
|
|
51
51
|
.option(...commands_1.linux)
|
|
52
|
+
.option(...commands_1.remote)
|
|
52
53
|
.action(build_1.default);
|
|
53
54
|
program
|
|
54
55
|
.command('copy')
|
|
@@ -76,6 +77,7 @@ program
|
|
|
76
77
|
.option(...commands_1.mac)
|
|
77
78
|
.option(...commands_1.linux)
|
|
78
79
|
.option(...commands_1.auto)
|
|
80
|
+
.option(...commands_1.remote)
|
|
79
81
|
.action(publish_1.default);
|
|
80
82
|
program
|
|
81
83
|
.command('config [name]')
|
package/lib/commands/option.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const pack: readonly ["--pack", "是否使用hbuilderx构建应
|
|
|
22
22
|
export declare const wgt: readonly ["--wgt", "是否构建移动应用热更新资源"];
|
|
23
23
|
export declare const res: readonly ["--res", "是否构建移动应用本地资源"];
|
|
24
24
|
export declare const auto: readonly ["-a, --auto", "自动发布,跳过所有确认"];
|
|
25
|
+
export declare const remote: readonly ["--remote", "是否从远程拉取资源构建"];
|
|
25
26
|
export declare const hbuilderxCli: readonly ["--cli.hbuilderx <cli-path>", "HbuilderX Cli路径"];
|
|
26
27
|
export declare const weixinCli: readonly ["--cli.weixin <cli-path>", "微信开发者工具 Cli路径"];
|
|
27
28
|
export declare const alipayCli: readonly ["--cli.alipay <cli-path>", "支付宝开发者工具 Cli路径"];
|
|
@@ -52,6 +53,7 @@ export interface Options {
|
|
|
52
53
|
win: boolean;
|
|
53
54
|
mac: boolean;
|
|
54
55
|
linux: boolean;
|
|
56
|
+
remote?: boolean;
|
|
55
57
|
'skill.repo'?: string;
|
|
56
58
|
'template.repo'?: string;
|
|
57
59
|
}
|
package/lib/commands/option.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.templateRepo = exports.skillRepo = exports.cosSecretkey = exports.cosSecretid = exports.alipayCli = exports.weixinCli = exports.hbuilderxCli = exports.auto = exports.res = exports.wgt = exports.pack = exports.custom = exports.zip = exports.linux = exports.mac = exports.win = exports.link = exports.path = exports.name = exports.clean = exports.ignore = exports.dest = exports.source = exports.branch = exports.env = exports.compiler = exports.project = exports.platform = exports.template = exports.version = void 0;
|
|
3
|
+
exports.templateRepo = exports.skillRepo = exports.cosSecretkey = exports.cosSecretid = exports.alipayCli = exports.weixinCli = exports.hbuilderxCli = exports.remote = exports.auto = exports.res = exports.wgt = exports.pack = exports.custom = exports.zip = exports.linux = exports.mac = exports.win = exports.link = exports.path = exports.name = exports.clean = exports.ignore = exports.dest = exports.source = exports.branch = exports.env = exports.compiler = exports.project = exports.platform = exports.template = exports.version = void 0;
|
|
4
4
|
exports.version = ['-v, --version', '输出版本号'];
|
|
5
5
|
exports.template = ['-t, --template <template-name>', '模版仓库名称'];
|
|
6
6
|
exports.platform = ['-p, --platform <platform-name>', '编译平台,默认h5', 'h5'];
|
|
@@ -24,6 +24,7 @@ exports.pack = ['--pack', '是否使用hbuilderx构建应用'];
|
|
|
24
24
|
exports.wgt = ['--wgt', '是否构建移动应用热更新资源'];
|
|
25
25
|
exports.res = ['--res', '是否构建移动应用本地资源'];
|
|
26
26
|
exports.auto = ['-a, --auto', '自动发布,跳过所有确认'];
|
|
27
|
+
exports.remote = ['--remote', '是否从远程拉取资源构建'];
|
|
27
28
|
exports.hbuilderxCli = ['--cli.hbuilderx <cli-path>', 'HbuilderX Cli路径'];
|
|
28
29
|
exports.weixinCli = ['--cli.weixin <cli-path>', '微信开发者工具 Cli路径'];
|
|
29
30
|
exports.alipayCli = ['--cli.alipay <cli-path>', '支付宝开发者工具 Cli路径'];
|
package/lib/commands/platform.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.h5 = exports.mp = exports.app = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const config_1 = require("../
|
|
6
|
+
const config_1 = require("../utils/config");
|
|
7
7
|
const config = (0, config_1.getLocalConfig)();
|
|
8
8
|
const app = (opts) => {
|
|
9
9
|
const { android: _android, ios: _ios, wgt: _wgt, custom, ...rest } = config?.app ?? {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getLocalConfig } from './
|
|
1
|
+
export { getLocalConfig } from './utils/config';
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLocalConfig = void 0;
|
|
4
|
-
var config_1 = require("./
|
|
4
|
+
var config_1 = require("./utils/config");
|
|
5
5
|
Object.defineProperty(exports, "getLocalConfig", { enumerable: true, get: function () { return config_1.getLocalConfig; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const publish_1 = require("./publish");
|
|
6
|
+
async function default_1() {
|
|
7
|
+
const manifest = (0, utils_1.readManifest)();
|
|
8
|
+
await (0, publish_1.publish)({
|
|
9
|
+
ext: 'apk',
|
|
10
|
+
name: 'app-release',
|
|
11
|
+
path: 'app/build/outputs/apk/release',
|
|
12
|
+
versionName: manifest['versionName'],
|
|
13
|
+
versionCode: manifest['versionCode'],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const publish_1 = require("./publish");
|
|
6
|
+
async function default_1() {
|
|
7
|
+
const manifest = (0, utils_1.readManifest)();
|
|
8
|
+
await (0, publish_1.publish)({
|
|
9
|
+
ext: 'wgt',
|
|
10
|
+
name: manifest['appid'],
|
|
11
|
+
path: 'unpackage/release',
|
|
12
|
+
versionName: manifest['versionName'],
|
|
13
|
+
versionCode: manifest['versionCode'],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const const_1 = require("../utils/const");
|
|
7
|
+
const publish_1 = require("./publish");
|
|
8
|
+
async function default_1() {
|
|
9
|
+
const pkg = (0, fs_extra_1.readJsonSync)((0, path_1.join)(const_1.COMMAND_PATH, 'package.json'));
|
|
10
|
+
await (0, publish_1.publish)({
|
|
11
|
+
ext: 'zip',
|
|
12
|
+
name: pkg['name'],
|
|
13
|
+
path: 'unpackage/release',
|
|
14
|
+
versionName: pkg['version'],
|
|
15
|
+
versionCode: pkg['versionCode'],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const const_1 = require("../utils/const");
|
|
7
|
+
const publish_1 = require("./publish");
|
|
8
|
+
async function default_1() {
|
|
9
|
+
const pkg = (0, fs_extra_1.readJsonSync)((0, path_1.join)(const_1.COMMAND_PATH, 'package.json'));
|
|
10
|
+
await (0, publish_1.publish)({
|
|
11
|
+
ext: 'exe',
|
|
12
|
+
name: 'app-release',
|
|
13
|
+
path: 'dist',
|
|
14
|
+
versionName: pkg['version'],
|
|
15
|
+
versionCode: pkg['versionCode'],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const publish_1 = require("./publish");
|
|
6
|
+
async function default_1() {
|
|
7
|
+
const manifest = (0, utils_1.readManifest)();
|
|
8
|
+
await (0, publish_1.publish)({
|
|
9
|
+
ext: 'zip',
|
|
10
|
+
name: manifest['appid'],
|
|
11
|
+
path: 'unpackage/release',
|
|
12
|
+
versionName: manifest['versionName'],
|
|
13
|
+
versionCode: manifest['versionCode'],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|